Boost C++ Libraries: Ticket #1154: tss destruction segfaults in conjunction with dlopen/dlclose https://svn.boost.org/trac10/ticket/1154 <p> The attached code (a main program that loads a "plugin" library with dlopen and calls a function therein, then unloads it with dlclose before exiting normally) works fine with Boost 1.33.1, but segfaults on exit with 1.34.1 (observed on x86_64 with Linux 2.6.20 / glibc 2.5 / gcc 4.1.2). </p> <p> The segfault appears to occur because, in the new version, the boost::function objects wrapping the cleanup functions are all kept until there no longer any thread_specific_ptr objects of *any* type remaining. </p> <p> Since the main program keeps a thread_specific_ptr across the dlopen/dlclose calls, and the "plugin" library created a thread_specific_ptr to a type that only exists within that library, the boost::function internals for the cleanup function on that local type are only instantiated within the library. Hence delaying its destruction until program exit (after the call to dlclose) leads to a segfault because the internals of this boost::function type have now been unloaded. </p> <p> The attached Makefile should build the testcase, but you'll probably need to modify the top two lines (LDLIBS and CPPFLAGS) to point to your Boost headers and libraries. </p> <p> I appreciate that this code has been reworked in order to reduce the use of (potentially limited) thread-local storage slots on the system -- is it possible to retain this while still having each instance of thread_specific_ptr manage and destroy its own cleanup function rather than deferring the destruction of all cleanup functions until program exit? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1154 Trac 1.4.3 Zak Kipling <zak@…> Thu, 09 Aug 2007 12:25:51 GMT attachment set https://svn.boost.org/trac10/ticket/1154 https://svn.boost.org/trac10/ticket/1154 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">Makefile</span> </li> </ul> <p> Makefile to build test case </p> Ticket Zak Kipling <zak@…> Thu, 09 Aug 2007 12:26:21 GMT attachment set https://svn.boost.org/trac10/ticket/1154 https://svn.boost.org/trac10/ticket/1154 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main.cc</span> </li> </ul> <p> Source to main program of test case </p> Ticket Zak Kipling <zak@…> Thu, 09 Aug 2007 12:26:41 GMT attachment set https://svn.boost.org/trac10/ticket/1154 https://svn.boost.org/trac10/ticket/1154 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">plugin.cc</span> </li> </ul> <p> Source to plugin library of test case </p> Ticket Anthony Williams Thu, 02 Oct 2008 16:03:59 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1154#comment:1 https://svn.boost.org/trac10/ticket/1154#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Unable to reproduce with current trunk. I believe the cause was fixed in 1.35. </p> Ticket