On Fri, Oct 22, 2010 at 4:32 AM, Andrew Haley <aph@xxxxxxxxxx> wrote: > Please stop top-posting. It makes it very hard to reply to you. > > On 10/21/2010 09:01 PM, Alexey Skidanov wrote: >> Actually, you claim that if some static library defines some global variable, >> then it should NOT be linked with more then one shared library. > > In the same process, yes. That's absolutely true. > >> That is, if you >> have the dependencies tree like in my example then you have a problem. Think >> about such static library is third party library where I can't change the code. >> >> Regarding the ODR. You are absolutly right. But what about a MULTIPLE variable >> initialization. Is it correct behaviour according to standard? > > I don't know what you mean by a "MULTIPLE variable initialization". I believe he means the constructor running multiple times (the antithesis of the destructor running multiple times). I had the same question, but constructors are not causing a crash, so I have not pursued it :/ ________________________________ >> From: Andrew Haley <aph@xxxxxxxxxx> >> To: noloader@xxxxxxxxx >> Cc: Alexey Skidanov <Alexey.Skidanov@xxxxxxxxxxxx>; gcc-help@xxxxxxxxxxx; >> skidanovalexey@xxxxxxxxx >> Sent: Thu, October 21, 2010 7:37:25 PM >> Subject: Re: Global variable in static library - double free or corruption error >> >> On 10/21/2010 05:23 PM, Jeffrey Walton wrote: >>>> that there can only ever be one definition of a symbol in a program, and >>>> UNIX has always merged multiple definitions to achieve this >>> Does the rule include that gloabl object destructors are to run on >>> every unload, or the last/final unload or last call to dlclose (when >>> the shared object gets unmapped)? >> >> I suspect that Bad Things would happen. :-) >> >> As far as I know, they are run, and if you have two definitions >> of some object with a destructor, then you violate the ODR rule, >> and it's all your fault! >> >>> Many folks don't expect their >>> objects will be pulled out from under them until the last unload. It >>> seems like a reasonable expectation to me. >> >> Sure, but you break the rules, you get to keep all the pieces. >> >> Andrew. >> >> >> >> > >