Re: SEGV when dlopen()ing Gnome code



On Sat, Feb 10, 2001, Sean Middleditch wrote:

> OK, not sure if I'm totally getting this - you're loading a library (GNOME)
> with dlopen(), then trying to dlclose() the library without unintializing
> it first, so that all the functions/data setup in memory for the X server,
> signal handlers, and atexit() calls are no longer loaded into memory when
> the callbacks start occuring?

   Exactly. But dlclose() works fine, and the programs continues running
flawlessly. My problem is that I only get a segfault at exit().

> I think you need to shutdown the GNOME libraries before you close them.  I
> don't know if the GNOME libraries have a way of completely closing/removing
> all their callbacks.  If not, you can always use atexit() to set a callback
> that will dlclose() the library.

   Hey, that's a great hint ! It's not exactly the way I need to do
things, but atexit() is the clue: gtk and gdk use atexit() to register
callbacks at initialization time, which are called after dlclose in my
program.

   So I think I just need to see what has been put in these atexit()
callbacks, call them _before_ calling dlclose(), and find a way to
disable these atexit() callbacks.

Many thanks,
Sam.
-- 
Samuel Hocevar <sam zoy org> <http://sam.zoy.org/>
for DVDs in Linux screw the MPAA and ; do dig $DVDs.z.zoy.org ; done | \
      perl -ne 's/\.//g; print pack("H224",$1) if(/^x([^z]*)/)' | gunzip




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]