Re: SEGV when dlopen()ing Gnome code



Sean Middleditch wrote:

> Perhaps someone could write a cleaner gnome_shutdown (or gtk_shutdown)
> function that calls the shutdown callbacks, and makes sure they are
> unregistered from where-ever g_atexit registers them.  This would be useful
> for a lot of people, especially those who are writing apps that can use
> multiple GUI's, selecting which one at run-time (correct me if I'm wrong,
> but doesn't OMS work like this?  perhaps we could see how they did it).

Well, if you are not very much concerned about portability, shutdown
callbacks from shared objects are usually implemented in the "shutdown"
part of the shared object. So, instead of g_atexit() being implemented
by calling atexit(), it would have to be implemented just like atexit() is
(saving pointers to shutdown functions somewhere) and then the destructor
part of the shared object would have to call them.

The problem with this approach is that it's OS[1] *and* compiler specific,
so it's not easy to implement and test on all interesting combinations
of operating systems and compilers.

[1] It's mostly file format specific, so all OS's which use ELF (for
    example) handle it in a similar way, ie. in ELF's .fini segment.
    Except when they don't. I think SunOS doesn't call .init when
    you dlopen() a library. I'm not sure whether it calls .fini
    when you dlclose() it, but be prepared for a few surprises if
    you take this road.

-- 
 .-.   .-.    Sarcasm is just one more service we offer.
(_  \ /  _)
     |        dave arsdigita com
     |




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