Bug in dlopen using static objects ?

Mike Stump mrs@wrs.com
Thu Dec 10 10:55:00 GMT 1998


> Date: Wed, 09 Dec 1998 17:21:08 +0100
> From: Arthur Rother <arthur.rother@ovidius.com>

> The main problem is:

> I am loading a library using the dlopen call from the dl library.
> In the dynamic loaded library I call a function, which constructs a
> static object, which implements amongst others a destructor.

> After a call to dlclose, this object is not destroyed. On
> terminating the program, it does try to destroy the object, but the
> reference to the destructor member of that object is ofcourse
> invalid (since the library was freed).

A bug, unless someone steps forward to fix this, it'll probably be a
problem for a while.  What needs to be done (IMHO) is to have a per
module dynamic dtor list and run it at module dtor time, and put in a
hook for users (or the system) to call before the unload.

All the global dtors as well as the one atexit style dtor in decl.c
need to use the same mechanism.

This has been discussed before on this list, you might try the
archives for more information.



More information about the Gcc-bugs mailing list