This is the mail archive of the libc-alpha@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug with dlclose and static class elements


>>>>> "HH" == Harald Hoyer <Harald.Hoyer@hot.spotline.de> writes:

HH> Hi,

HH> the attached tarball demonstrates the failure of deleting static elements in
HH> classes, if the library that contains these class is unloaded with dlclose.

HH> My question is whether this is a glibc (libdl) bug or a bug in generating the
HH> code (egcs).

HH> System is Linux kernel 2.2.0, glibc 2.0.111, gcc version egcs-2.91.58 19981101
HH> (egcs-1.1.1 pre-release).

It also happens with g++2.8.1 and related bug occurs with g++2.7.2

The problem is someone getting clever, in generating code, in 2.8.x.
The instead of putting the a call to the destructor in the .dtors section
atexit is called.  

When dlclose is called the function is removed, and then when atexit
attempts to call the destructor it dies because the code is gone.


HH> Bug showed up in all older versions of kernel, libc and egcs.

HH> If this bug is known could you please point me to a fix.

A simple fix is to give your static file scope, and not function scope.

HH> If this bug is unknown I likely want to know, if it could be fixed in the recent
HH> future.

I don't know about fixing right but I have tracked it ;)

Eric


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]