Subject: bug#6301: 23.2.50; GC may lose Lisp objects in the image cache

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Sat, 29 May 2010 17:37:43 +0900

Currently, Fgarbage_collect calls mark_terminals after marking
staticpro'ed objects.  Terminal objects need a special marking
strategy with respect to image cache, but if a terminal object is
reachable from some staticpro'ed object, then it is marked normally
(i.e., without considering image cache).  As a result, Lisp objects in
the image cache might be collected though they should have been
marked.

The simplest way to fix this would be to call mark_terminals earlier.
Actually, the latest release of the Mac port includes the following
patch.

				     YAMAMOTO Mitsuharu
				[email-masked]

=== modified file 'src/alloc.c'
*** src/alloc.c	2010-01-22 09:10:04 +0000
--- src/alloc.c	2010-05-29 07:58:30 +0000
*************** returns nil, because real GC can't be do
*** 5088,5093 ****
--- 5088,5097 ----
  
    /* Mark all the special slots that serve as the roots of accessibility.  */
  
+   /* Terminals need to be marked in a special way.  But they can be
+      reachable from other roots and might be marked normally if
+      mark_terminals is called later.  */
+   mark_terminals ();
    for (i = 0; i < staticidx; i++)
      mark_object (*staticvec[i]);
  
*************** returns nil, because real GC can't be do
*** 5096,5102 ****
        mark_object (bind->symbol);
        mark_object (bind->old_value);
      }
-   mark_terminals ();
    mark_kboards ();
    mark_ttys ();
  
--- 5100,5105 ----