dlclose not calling destructors of static variables.
Andrew West
andrewwest@gmail.com
Fri Jan 29 14:59:00 GMT 2010
On 29/01/2010 13:08, Dave Korn wrote:
> On 28/01/2010 11:21, Andrew West wrote:
>
>> I seem to be having a problem with dlclose not calling the destructors
>> of statically declared variables. I've attached a simple test case which
>> I compile as follows;
>>
> Thanks for the report and the STC; this should work. I'll take a look at it
> over the weekend or the start of next week if nobody else gets there first.
>
> cheers,
> DaveK
>
>
Thanks for looking into this, it looks a little more complex than I
first thought.
I've tried calling __call_exitprocs during dlclose ( after run_dtors for
the unloading library ) just to see if I was thinking along the right
lines. Unfortunately this didn't work as when the destructor is
registered with atexit it isn't associated with the loaded library but
with the main executable.
Which brings me on to the bigger problem, the static variables are
registered with atexit rather than with __cxa_atexit which seems to be a
violation of the C++ standard (1).
Worse still gcc isn't compiled with cxa_atexit enabled. So I assume the
right course of action here is to enable __cxa_atexit in gcc, and then
make sure __cxa_finalize gets called when the library is unloaded?
Andy.
1)
http://refspecs.linux-foundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/baselib---cxa-atexit.html
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list