This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Global variable in static library - double free or corruption error
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: Alexey Skidanov <Alexey dot Skidanov at orbotech dot com>, gcc-help at gcc dot gnu dot org, skidanovalexey at yahoo dot com
- Date: Thu, 21 Oct 2010 12:23:06 -0400
- Subject: Re: Global variable in static library - double free or corruption error
- References: <B82EE7AE3CBADB41BB289C2270B2B51102613C79@excg-isl01> <4CC065EA.1000800@redhat.com>
- Reply-to: noloader at gmail dot com
> 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)? 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.
> it's just something to get used to
Agreed.
On Thu, Oct 21, 2010 at 12:10 PM, Andrew Haley <aph@redhat.com> wrote:
> On 10/21/2010 04:34 PM, Alexey Skidanov wrote:
>
>> Thanks for your response. You are absolutely right regarding to
>> -Wglobal-variable. I would prefer to get some kind of error (linking
>> error?) about two global variables with the same name instead of dynamic
>> loader/linker decision to "merge" them.
>
> This is standard, and correct behaviour. ?The One Definition Rule says
> that there can only ever be one definition of a symbol in a program, and
> UNIX has always merged multiple definitions to achieve this. ?Also, plenty
> of programs depend on this behaviour: it's just something to get used to.
>
> Andrew.
>