[Gc] [PATCH] Allow registration of disappearing links on non-heap objects

Ludovic Courtès ludo at gnu.org
Sat Jan 31 10:10:52 PST 2009


In 7.1, registering disappearing links on non-heap objects leads to a
segmentation fault as illustrated with this program:

  #include <gc/gc.h>

  static const int foo;

  main (int argc, char *argv[])
    void *link;

    GC_INIT ();

    link = (void *) &foo;
    GC_gcollect ();  /* <-- triggers the segfault */

    return 0;

The backtrace is as follows:

  #0  GC_is_marked (p=0x109 <Address 0x109 out of bounds>) at mark.c:232
  #1  0xb7fa2c02 in GC_finalize () at finalize.c:507
  #2  0xb7f9f7b2 in GC_finish_collection () at alloc.c:656
  #3  0xb7f9fe09 in GC_try_to_collect_inner (stop_func=0xb7f9ef20 <GC_never_stop_func>) at alloc.c:373
  #4  0xb7fa00b4 in GC_try_to_collect (stop_func=0xb7f9ef20 <GC_never_stop_func>) at alloc.c:762
  #5  0xb7fa0190 in GC_gcollect () at alloc.c:774
  #6  0x08048649 in main () at ,,disappearing-link-on-non-heap-object.c:14

The attached patch fixes the problem.  However, I'm not sure whether
that behavior was actually on purpose; if it was, it should be
documented rather than patched.  (I haven't checked whether this area
has changed in CVS.)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ,,disappearing-link-on-non-heap-object.diff
Type: text/x-patch
Size: 534 bytes
Desc: The patch, against 7.1
Url : https://napali.hpl.hp.com/pipermail/gc/attachments/20090131/3b0867ef/disappearing-link-on-non-heap-object.bin

More information about the Gc mailing list