Re: Runtime Link-Loader Behavior and ODR (Is this a Bug?)

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

 



On Sat, Oct 23, 2010 at 6:46 PM, Jeffrey Walton <noloader@xxxxxxxxx> wrote:
> I have a few questions regarding ABI, ODR, and the Runtime Link-Loader.
>
> Here's the scenario that Crypto++ was taking bug reports on when
> maintainers decided to start packaging Crypto++ as a DSO.
>
> ==========
>
>
>            +----- Some Plugin/DSO 1 -----\
>            |                              \
> apache -----+                                +----- Crytpo++ DSO
>            |                              /
>            +----- Some Plugin/DSO 2 -----/
>
> * (best viewed with fixed font)
>
> ==========
>
> Crypto++ DSO declares a global C++ class which has a destructor. Call
> it g_Global. g_Global is declared once in Crypto++, and storage is
> allocated for it
> Crypto++ DSO .
>
> Apache, Some Plugin/DSO 1, and Some Plugin/DSO 2 do not
> declare it and do not provide a storage allocation for it.
>
> [SNIP]
>
> ==========
>
> Apache unloads Some Plugin/DSO 1. The destructor for g_Global
>    *IS* executed.
> Apache unloads Some Plugin/DSO 2. The destructor for g_Global
>     *IS* executed. <== Crash*

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).

In addition, I don't believe this is a violation of ODR. Section 3.5
specifies that the named variable is the same object, which brings me
back to, "Why are constructors and destructors running multiple
times?".

> ==========
>
> Apache loads Some Plugin/DSO 1. The constructor for g_Global
>     is executed.
> Apache loads Some Plugin/DSO 2. The constructor for g_Global
>    *IS NOT* executed.
This was probably incorrect - constructors are probably running
multiple times. It has not caused a crash, so it its probably causing
a leak at worst (as someone else pointed out).

Jeff

[1] Free version, http://www-d0.fnal.gov/~dladams/cxx_standard.pdf



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux