[Gc] Potential bug in dyn_load.c

Mike Hearn mike at navi.cx
Mon Aug 30 07:21:58 PDT 2004


In the course of compiling libgc in unusual ways, I seem to have found a
bug in the GC_register_dynamic_libraries() function. In particular when
dl_iterate_phdrs is not defined (ie on a very old glibc system) the
codepath taken segfaults because lm->l_addr is NULL.

I know a bit about ELF and can't really figure this code out.
GL_FirstDLOpenedLinkMap is looking for the DT_DEBUG header, however this
header is not mandatory. It's present in all gnu toolchain generated
binaries by co-incidence, so it doesn't seem very safe to me. I'm also
not sure what it's doing with the result: DT_DEBUG often points nowhere,
and this seems to the problem here as it returns a link map with an
address of zero which is dereferenced causing a crash.

I know why dl_iterate_phdrs isn't being used in my particular case and
will fix it now but I thought you might want a bug report as this
codepath is unlikely to be used often.

thanks -mike

More information about the Gc mailing list