libtool
[Top][All Lists]
Advanced

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

Re: statics, dlclose, and libstdc++


From: Michael Matz
Subject: Re: statics, dlclose, and libstdc++
Date: Sat, 10 Feb 2001 09:09:04 +0100 (MET)

Hi,

On Fri, 9 Feb 2001, Wesley W. Terpstra wrote:
> 
> I was trying to write a php4 module. It gets dlopened and dlclosed. I am
> using c++. When the module gets dlclosed in apache it segfaults. I assume
> (from what I've been reading) that this is because I have a couple static
> variables in function scope in some of my c++ files and the desctructor is
> somehow confused.

Yep, that happens on linux. static C++ object in function scope simply
crash on dlclose().  static objects in file scope are mostly OK (but make
problems on other platforms).  Generally one should _painfully_ pay
attention to dlclose() in the reverse order of dlopen(), as otherwise
the dynamic loader crashes (when C++ stuff is involved), even if only file
scope statics are used.

> What I don't understand is .. why? Doesn't c++ put stuff in the _fini
> symbol to clean up it's statics before it's pulled out of memory? 

One would think, but somehow the dynamic loader gets confused by
_init/_fini.  In purely C environments the use of both functions is
seldom.  In the past, when we had many problems with that in KDE I
debugged ld.so, but somewhen gave up without a result ;)


Ciao,
Michael.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]