Runtime Link-Loader Behavior and ODR (Is this a Bug?)
Jeffrey Walton
noloader@gmail.com
Wed Oct 27 15:13:00 GMT 2010
On Wed, Oct 27, 2010 at 12:23 AM, Ian Lance Taylor <iant@google.com> wrote:
> Jeffrey Walton <noloader@gmail.com> writes:
>
>> I've familiarized myself with ISO/IEC 14882 [1] and section 3.5
>> Program and Linkage. If a variable (g_Global above) satisfies
>> paragraph/clause (9) (ie, names using external linkage in different
>> scopes denotes the same object), where is it stated that constructors
>> and destructors will run multiple times? I have not found anywhere in
>> the standard where an object's constructor and destructors should be
>> executed multiple times (cf, Section 12 Special member functions,
>> Subsection 1, Constructors).
>
> The C++ standard doesn't cover shared libraries, so this is all outside
> the scope of the standard.
>
> That said, I don't think that constructors should run multiple times in
> this scenario, and I really can not explain what you are seeing. Can
> you construct a small self-contained example with a series of commands
> to run to show the problem?
My simple test cases using Foo and Bar cannot duplicate. Using a live
libcryptopp can cause a crash with dlopen and friends, but I have not
been able to reduce it to something useful for a bug report.
Possibly related: I did an audit of all SOs on a 'stock plus some'
Ubuntu installation. 'plus some' includes the tool chain, emacs,
OpenOffice and a few others. Nearly 300 of the 3500 crashed on a
dlopen/dlclose cycle. I can't explain the [nearly] 10% failure rate,
but I have not looked for the cause either.
Jeff
More information about the Gcc-help
mailing list