[Gc] object collected while still in use - test case

Chris Moore christopher.ian.moore at gmail.com
Thu Oct 18 00:04:50 PDT 2007


Hi there.

I recently started trying to use libgc, and pretty quickly came up
against a problem where objects are being freed while still in use.

I managed to make a relatively small test case:

    http://dooglus.rincevent.net/random/gc.cpp (1177 bytes)

I'm building like this:

  g++ -I/usr/local/include gc.cpp /usr/local/lib/libgc.so

I'm seeing this output:

new layer at 807dff0
layer's address is 807dff0 ; x = 28
  doing GC
    destroy layer at 807dff0
  done GC - but I still have a pointer to the layer:
layer's address is 807dff0 ; x = 29

If I comment out the "obj=0;" statement on line 17 then the early free
doesn't happen any more.
Similarly, if I uncomment the commented printf() on line 37 the
problem goes away.

I've tried versions 7.0 and 6.8 of gc and both give the same results.

I've built gc with various combinations of options, but don't see any
difference.

Am I doing anything silly?  Or is this a bug?


This is on Ubuntu Feisty (7.04) with:
ii  g++            4.1.2-1ubuntu1 The GNU C++ compiler
ii  libc6          2.5-0ubuntu14  GNU C Library: Shared libraries
$ uname -a
Linux trpaslik 2.6.20-16-generic #2 SMP Sun Sep 23 19:50:39 UTC 2007
i686 GNU/Linux
$ grep model /proc/cpuinfo
model		: 14
model name	: Genuine Intel(R) CPU           T2500  @ 2.00GHz
model		: 14
model name	: Genuine Intel(R) CPU           T2500  @ 2.00GHz
$


Thanks in advance,

Chris.


More information about the Gc mailing list