[Gc] Crash in collector after adjusting root set

Laurynas Biveinis laurynas.biveinis at gmail.com
Sun Jun 18 05:25:54 PDT 2006


I'm experimenting with Boehm's GC as a garbage collector for GCC.
Since not whole memory is managed by GC, I have to take care to
register additional roots living in malloc'ed memory with
GC_add_roots(). Majority of them are constant during program lifetime.
However there is a malloc'ed hash table of identifiers that may get
moved for expansion. If it moves I try to adjust collector's idea of
root set by calling GC_remove_roots() for the old table and
registering the new roots with GC_add_roots(). I've checked with
GC_dump that after this collector has the correct set of roots.

But after that first GC_collect() call crashes with

Program received signal SIGSEGV, Segmentation fault.
0x01046191 in GC_mark_from (mark_stack_top=0x22e7b4, mark_stack=0x0,
    mark_stack_limit=0x0) at ../../../gcc-boehm-test/boehm-gc/mark.c:759
759               deferred = *limit;
(gdb) bt
#0  0x01046191 in GC_mark_from (mark_stack_top=0x22e7b4, mark_stack=0x0,
    mark_stack_limit=0x0) at ../../../gcc-boehm-test/boehm-gc/mark.c:759
#1  0x00000000 in ?? () from

The collector is compiled with all debugging options I could find:
"--enable-gc-debug --enable-full-debug"  CFLAGS="-DKEEP_BACK_PTRS
-DGC_ASSERTIONS -g -O2", incremental collection is disabled
(additionally GC_dont_precollect is set). The collector is set up not
to collect on allocation, but rather when explicitly invoked. Platform
is i686-pc-cygwin.

I've tried not freeing, but zeroing out the old location of the hash
table, and not removing it from the root set - but the crash is
exactly the same.

Any clues what went wrong here?


More information about the Gc mailing list