Note that there are some explanatory texts on larger screens.

plurals
  1. POWrong statics destruction order after opening/closing a shared library more than once
    primarykey
    data
    text
    <p>I have a weird problem with a C++ shared library on Linux.</p> <p>The process loads and unloads my library twice (it is by design and cannot be changed). </p> <ol> <li>During the first dlopen(), all static members in my library are initialized in a corrected order. </li> <li>Then, when the first dlclose() is called, the destruction goes also as expected, in the order opposite to the construction.</li> <li>During the second dlopen(), everything is okay - the order of construction is correct, same as the first time.</li> <li>But on the second dlclose() the order of destruction suddenly gets broken - the destructors are called in the same order as they were initialized, and it often causes a SEGFAULT if any static object attempts to access an already destroyed object. </li> <li>Subsequent attempts to dlopen()/dlclose() repeat the 3rd and 4th steps exactly. </li> </ol> <p>I've attempted to reproduce the problem with a minimal example, but did not succeed - with a small fake shared library everything works as expected. There is something in my large library that causes the havoc on the second dlclose(), and it is very large.</p> <p>I did not find dependency on gcc (tried 3.2/3.4/4.1.2) nor Linux distro (RHEL 4/5, SuSE 10). Search for similar cases in Web resulted in 0 results - nothing similar.</p> <p>During the experiments, I've tried to embed a few calls to atexit() in static object constructors, to see if the order of atexit() handlers gets affected, and found that it does. Steps 1/2/3 works well (dlopen/dlclose/dlopen), then on the second dlclose the order of the atexit-registered handlers is incorrect.</p> <p>I don't really expect to get an answer, but I would most appreciate any suggestions of how to pursue the problem. </p> <p>Thank you in advance,</p> <p>Andrew Schetinin</p> <p>P.S. Update - I debugged the code in atexit() in GLIBC and found that there is a bug I'm hitting - quite a simple bug, actually. It is fixed in GLIBC 2.4, and I was unlucky to work with GLIBC 2.3.4</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload