[Gc] Don't mark for dead thread(s)

NIIBE Yutaka gniibe at fsij.org
Fri Apr 16 00:43:04 PDT 2010


I encounter a bug on ia64 with GNU/Linux, when I tried
DONT_ADD_BYTE_AT_END enabled.

The situation is that 'gctest' program fails in the for loop
of GC_set_fl_marks (with a stale pointer).

I found that the owner of the normal_freelist was a thread of
tiny_reverse_test, just finished, but not have joined yet.
GC_destroy_thread_local called already, but GC_delete_thread not yet.

Here is my fix.  All tests go well with this fix.

I don't know the reason why DONT_ADD_BYTE_AT_END reveals this bug
though.

2010-04-16  NIIBE Yutaka  <gniibe at fsij.org>

	* pthread_support.c (GC_mark_thread_local_free_lists): Mark only
	for live threads.

Index: pthread_support.c
===================================================================
RCS file: /cvsroot/bdwgc/bdwgc/pthread_support.c,v
retrieving revision 1.59
diff -u -p -r1.59 pthread_support.c
--- pthread_support.c	5 Mar 2010 14:26:16 -0000	1.59
+++ pthread_support.c	16 Apr 2010 06:56:02 -0000
@@ -227,7 +227,9 @@ GC_INNER void GC_mark_thread_local_free_

      for (i = 0; i < THREAD_TABLE_SZ; ++i) {
        for (p = GC_threads[i]; 0 != p; p = p -> next) {
-        GC_mark_thread_local_fls_for(&(p->tlfs));
+            if (!(p -> flags & FINISHED)) {
+              GC_mark_thread_local_fls_for(&(p->tlfs));
+            }
        }
      }
  }


More information about the Gc mailing list