[Gc] gc6.3: ALL_INTERIOR_POINTERS & DONT_ADD_BYTE_AT_END

Shiro Kawai shiro at lava.net
Mon Sep 13 20:20:22 PDT 2004


While I'm adopting gc6.3 to my program, I noticed that gctest got
into infinite loop if I turn on both ALL_INTERIOR_POINTERS
and DONT_ADD_BYTE_AT_END.  I made a fix to a suspicious place, but
I don't know if it is correct.

Platform:
  Linux 2.4.20/22 + nptl on ix86, glibc 2.3.2, gcc 3.2.2 and 3.3.2
  (Basically, RHL9.0 and Fedore Core 1.0)

How to reproduce:
  - Apply the following patch to gc6.3 source
  - autoconf + configure + make
  - make check

======================
--- configure.in.orig	2004-09-13 16:52:43.000000000 -1000
+++ configure.in	2004-09-13 15:32:03.000000000 -1000
@@ -379,6 +379,7 @@
 AC_DEFINE(NO_SIGNALS)
 AC_DEFINE(NO_EXECUTE_PERMISSION)
 AC_DEFINE(ALL_INTERIOR_POINTERS)
+AC_DEFINE(DONT_ADD_BYTE_AT_END)
 
 dnl By default, make the library as general as possible.
 AC_DEFINE(JAVA_FINALIZATION)
======================

Symptom:
 Test hangs after printing the line:

  Emulating dirty bits with mprotect/signals

 Stack trace follows:

=====================
(gdb) thread 1
[Switching to thread 1 (Thread -1084579168 (LWP 12942))]#0  0x0021e110 in GC_extend_size_map (i=2048) at misc.c:225
225                 while (GC_size_map[low_limit] != 0) low_limit++;
(gdb) bt
#0  0x0021e110 in GC_extend_size_map (i=2048) at misc.c:225
#1  0x0021a9a3 in GC_generic_malloc_inner (lb=2048, k=1) at malloc.c:124
#2  0x0021aacc in GC_generic_malloc (lb=2048, k=1) at malloc.c:192
#3  0x0021ad5d in GC_malloc (lb=2048) at malloc.c:297
#4  0x002218b3 in GC_malloc_stubborn (lb=2048) at stubborn.c:307
#5  0x08049436 in cons (x=0x600, y=0x600) at tests/test.c:178
#6  0x080497b7 in reverse1 (x=0x9a2e000, y=0x600) at tests/test.c:371
#7  0x080497d4 in reverse (x=0x9a1e000) at tests/test.c:381
#8  0x08049d73 in reverse_test () at tests/test.c:679
#9  0x0804ab22 in run_one_test () at tests/test.c:1323
#10 0x0804afad in main () at tests/test.c:1830
(gdb) thread 2
[Switching to thread 2 (Thread -1095070800 (LWP 12960))]#0  0x0040fc32 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
(gdb) bt
#0  0x0040fc32 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1  0x00d6e7bb in __lll_mutex_lock_wait () from /lib/tls/libpthread.so.0
#2  0x000032a0 in ?? ()
#3  0x0022a338 in __JCR_LIST__ () from /home/shiro/src/gc6.3/.libs/libgc.so.1
#4  0x08059730 in GC_least_plausible_heap_addr ()
#5  0x00d6b976 in _L_mutex_lock_26 () from /lib/tls/libpthread.so.0
#6  0x00000011 in ?? ()
#7  0xbeba89e8 in ?? ()
#8  0x002238e2 in GC_lock () at pthread_support.c:1467
Previous frame identical to this frame (corrupt stack?)
(gdb) thread 3
[Switching to thread 3 (Thread -1084580944 (LWP 12959))]#0  0x0040fc32 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
(gdb) bt
#0  0x0040fc32 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1  0x00d6e7bb in __lll_mutex_lock_wait () from /lib/tls/libpthread.so.0
#2  0x0000329f in ?? ()
#3  0x0022a338 in __JCR_LIST__ () from /home/shiro/src/gc6.3/.libs/libgc.so.1
#4  0x08059730 in GC_least_plausible_heap_addr ()
#5  0x00d6b976 in _L_mutex_lock_26 () from /lib/tls/libpthread.so.0
#6  0x09a05000 in ?? ()
#7  0xbf5a9938 in ?? ()
#8  0x002238e2 in GC_lock () at pthread_support.c:1467
Previous frame identical to this frame (corrupt stack?)

=====================

Fix?:
  It looks like GC_extend_size_map doesn't consider the case that
  GC_all_interior_pointers = 1 and defined(DONT_ADD_BYTE_AT_END).
  The following patch seems to work, but I'm not sure if this is
  correct, since this code hasn't been changed from 6.2.  

=====================
--- misc.c.orig	2004-03-13 12:38:09.000000000 -1000
+++ misc.c	2004-09-13 16:45:37.000000000 -1000
@@ -246,9 +246,8 @@
     	byte_sz = WORDS_TO_BYTES(word_sz);
 	if (GC_all_interior_pointers) {
 	    /* We need one extra byte; don't fill in GC_size_map[byte_sz] */
-	    byte_sz--;
+	    byte_sz -= EXTRA_BYTES;
 	}
-
     	for (j = low_limit; j <= byte_sz; j++) GC_size_map[j] = word_sz;  
     }
 # endif
=====================


--shiro


More information about the Gc mailing list