[Gc] GC and valgrind

Kenneth C. Schalk ken at xorian.net
Wed Jan 7 13:24:20 PST 2004


I've been trying to use valgrind in the hunt for a tough intermittent
stack smash in a program that uses the collector.  For anyone not
familiar with valgrind, it's home page is here:

http://valgrind.kde.org/

I figured I'd post some quick notes on what I've been doing, in case
anyone else is interested.  The changes I've made to the collector
itself are fairly minor:

- I increased HEAP_START (as valgrind assumes that the low 64k of
memory will always be inaccessible).

- I added uses of the VALGRIND_MAKE_NOACCESS macro after calls to mmap
in GC_unix_get_mem and GC_remap.  This tells valgrind that these
regions should be considered inaccessible to the application.

In the application I'm working with, all allocations using the
collector go through a central overloaded new operator.  At this point
I've used the VALGRIND_MALLOCLIKE_BLOCK macro to mark an allocated
block as accessible and added a finalizer that uses the
VALGRIND_FREELIKE_BLOCK macro to mark a block as inaccessible.

Finally, I've written a valgrind "suppression" file that tell valgrind
to ignore some things it would otherwise flag as errors inside the
collector itself (e.g. accessing the mmaped regions that I've told
valgrind to consider inaccessible).

Unfortunately, I've hit a snag with valgrind that's making it
impossible for me to move forward.  You can read my bug report here:

http://bugs.kde.org/show_bug.cgi?id=72082

I'm hoping to get this resolved and continue making progress.  I may
at some point be able to provide a patch that adds valgrind support to
the collector with a macro.

--Ken

P.S. I should say that this approach wouldn't be useful for debugging
the collector itself, only an application using it.


More information about the Gc mailing list