Re: SEGV when dlopen()ing Gnome code

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).

On 2001.02.10 02:12:54 -0500 Samuel Hocevar wrote:
> On Sat, Feb 10, 2001, Havoc Pennington wrote:
> > Yes, you can't expect dlopen()'ing an arbitrary library or application
> > to work. ;-)
>    Well, I just figured that :-)
> > There can be all sorts of stuff that gets set up that
> > depends on the lib/app code remaining loaded into the process.
> > 
> > I would imagine there are literally several thousand aspects of
> > glib/gtk/gnome-libs that break if you unload the library. They just
> > aren't designed for it.
>    I do not really agree -- exiting from an application shouldn't be
> very different from unloading a shared object. The only difference here
> is the atexit() callbacks. Actually, both gtk and gdk call g_atexit() to
> register stuff that is to be called on application exit.
>    This may be a practical way to do things, because one doesn't have to
> bother where data is unallocated, but it looks awful to me. I'd rather
> have these callbacks called at the end of gtk_main() or gnome_main().
>    For those interested, I found a workaround. It's absolutely ugly,
> and I don't recommend reading the next few sentences to people with
> epilepsy or heart problems. I export a function called g_atexit in my
> code, which stores the gtk and gdk callbacks in a private structure
> instead of calling atexit(). When dlopen()ing the shared object, my
> g_atexit symbol is resolved before Glib's one, which means that when
> calling gnome_init(), my private g_atexit is called. Then I call these
> stored callbacks just after gtk_main() has finished. The library can
> eventually be safely dlclosed().
>    Well, at least my application doesn't segfault on exit anymore and
> now loads and unloads its Gnome interface on request. But I agree this
> is rather kludgey.
> Regards,
> Sam.
> -- 
> Samuel Hocevar <sam zoy org> <>
> for DVDs in Linux screw the MPAA and ; do dig $ ; done | \
>       perl -ne 's/\.//g; print pack("H224",$1) if(/^x([^z]*)/)' | gunzip
> _______________________________________________
> gnome-devel-list mailing list
> gnome-devel-list gnome org
Sean Middleditch
AwesomePlay Productions, Inc.

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