[Gc] Segfault for certain sizes of GC_Thread_Rep
Petter Urkedal
urkedal at nbi.dk
Wed Sep 14 15:03:39 PDT 2011
I seem to have hit an segfault related to thread local storage. If I
add
--- a/include/private/thread_local_alloc.h
+++ b/include/private/thread_local_alloc.h
@@ -74,6 +74,7 @@ typedef struct thread_local_freelists {
/* Value used for gcj_freelist[-1]; allocation is */
/* erroneous. */
# endif
+ void * XXX[TINY_FREELISTS];
/* Free lists contain either a pointer or a small count */
/* reflecting the number of granules allocated at that */
/* size. */
to the current master branch, then the threadkey_test segfaults in about 1 out
of 1000 runs. This is on a 4 Core Xeon L5335 running Gentoo and the collector
is configured as
configure --enable-parallel-mark --enable-maintainer-mode --enable-threads=posix --disable-gcj-support --disable-static --enable-shared --enable-gc-assertions CFLAGS=-O0 -g3 -fstrict-aliasing -Wstrict-aliasing
Backtrace:
#0 0x00007ffba4976ca7 in GC_unregister_my_thread_inner (me=0x0)
at /home/urkedal/proj/bdwgc/pthread_support.c:1164
#1 0x00007ffba4976dd6 in GC_unregister_my_thread ()
at /home/urkedal/proj/bdwgc/pthread_support.c:1197
#2 0x0000000000400a8e in on_thread_exit_inner (sb=0x7ffa9efe8e70, arg=0x0)
at /home/urkedal/proj/bdwgc/tests/threadkey_test.c:53
#3 0x00007ffba496ea98 in GC_call_with_stack_base (fn=0x400a46 <on_thread_exit_inner>,
arg=0x0) at /home/urkedal/proj/bdwgc/misc.c:1522
#4 0x0000000000400ab0 in on_thread_exit (v=0xfffffffffe7cd06f)
at /home/urkedal/proj/bdwgc/tests/threadkey_test.c:60
#5 0x00007ffba4737115 in __nptl_deallocate_tsd () from /lib64/libpthread.so.0
#6 0x00007ffba4737a7b in start_thread () from /lib64/libpthread.so.0
#7 0x00007ffba429dddd in clone () from /lib64/libc.so.6
The other threads are halted in __lll_lock_wait (most), sem_wait,
pthread_cond_wait, GC_pause, and clone.
Adding
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -480,6 +480,7 @@ STATIC GC_thread GC_new_thread(pthread_t id)
result = (struct GC_Thread_Rep *)
GC_INTERNAL_MALLOC(sizeof(struct GC_Thread_Rep), NORMAL);
if (result == 0) return(0);
+ printf("%zd %zd - ", sizeof(struct GC_Thread_Rep), GC_size(result));
}
result -> id = id;
# ifdef PLATFORM_ANDROID
and experimenting with different sizes of the XXX array, I found that the bug
manifests for GC_size(result) = 672, but not for 576 or 800.
(Ivan, I'm holding back my merge request until we fix this.)
More information about the Gc
mailing list