Opened 15 years ago
Closed 14 years ago
#1154 closed Bugs (fixed)
tss destruction segfaults in conjunction with dlopen/dlclose
Reported by: | Owned by: | Anthony Williams | |
---|---|---|---|
Milestone: | To Be Determined | Component: | thread |
Version: | Boost 1.34.1 | Severity: | Regression |
Keywords: | Cc: |
Description
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).
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.
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.
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.
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?
Attachments (3)
Change History (4)
by , 15 years ago
comment:1 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Unable to reproduce with current trunk. I believe the cause was fixed in 1.35.
Makefile to build test case