[Gc] libgc without recompiling

Joe Buehler jbuehler at spirentcom.com
Mon Feb 28 06:27:28 PST 2005

I am working on patching libgc so it can be used against a binary
without recompiling the binary, on OS's that have support for this
sort of thing (LD_PRELOAD on linux and Solaris, for example).

When I do this under AIX, gctest core dumps when built with
thread support.  The garbage collector is examining memory that
is not part of the address space, leading to a SIGSEGV.

For AIX, I am using the MALLOCTYPE environment variable, which
allows me to intercept *all* malloc etc. calls, even ones internal
to the C library, which cannot otherwise be intercepted.  This will
behave a little differently than normal libgc usage, in that libgc
now sees all the malloc calls during the runtime setup, before
main() enters.

So my question concerns initialization.  There are comments
in the libgc override for malloc() that indicate that sbrk()
is used on Solaris during startup because pthreads init allocates
memory and libgc is not ready yet at that time for malloc calls.

Why is this?  Is it a matter of libgc trying to use pthread calls
before pthreads is initialized?
Joe Buehler

More information about the Gc mailing list