[gclist] GC debug (was: What to say about GC)

Jeremy Fitzhardinge jeremy@zip.com.au
Tue, 30 Jul 1996 11:24:48 +1000


William R. Dieter wrote:
> I, too, would be interested in hearing what other people do to debug.

The Boehm GC has a very useful debug mode.  For example, it will keep
sentinel values on either side of allocated blocks and checksum the
allocator's meta-data to guard against memory corruption.  The allocator
checks this when doing a mark, so I have the option to do a full GC
before and after every allocation to see exactly when various types of
corruption occur (very, very slow).  Also, by doing very regular GCs and
disabling threading, it can make otherwise non-deterministic bugs
deterministic.

It will also remember several levels of call frames for each allocated
block, which makes it easy to tell what a block is supposed to be based
on who allocated it.  This is really useful, since you can easily track
who's smashing an allocation by seeing what the memory above and below
the smashed object are.

I also have a 2nd allocator library which has the same interface as the
GC except it just uses malloc() and never frees.  I use that to tell for
sure whether a bug is GC related.

I have occasionally resorted to printing out painful amounts of detail
about the allocator's behaviour, but it gets boring very quickly, and
I've rarely found it useful.

	J