#12049 closed Bugs (fixed)
Assertion failure from detached threads during shutdown
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.61.0 | Component: | thread |
Version: | Boost 1.60.0 | Severity: | Regression |
Keywords: | Cc: |
Description
I'm observing assertion failures coming from detached threads during shutdown (i.e., the main thread is in static destruction):
libs/thread/src/pthread/thread.cpp:149: void boost::detail::set_current_thread_data(boost::detail::thread_data_base*): Assertion `!pthread_setspecific(current_thread_tls_key,new_data)' failed.
I'm seeing this on both Linux and Mac platforms; and the problem appears to have been introduced in the 1.60.0 release; 1.59.0 did not exhibit the problem.
Stacks from these threads at the time of the assertion failure look like this:
#0 0x00007fff95104002 in __pthread_kill () #1 0x000000010356944e in pthread_kill () #2 0x00007fff9ef566e7 in abort () #3 0x00007fff9ef1ddc7 in __assert_rtn () #4 0x0000000100a4ff90 in boost::detail::set_current_thread_data(boost::detail::thread_data_base*) at /Users/mcdanb/Build/buildpackages/API/pkg_build/boost_1_60_0/libs/thread/src/pthread/thread.cpp:149 #5 0x0000000100a50141 in boost::(anonymous namespace)::thread_proxy(void*) at /Users/mcdanb/Build/buildpackages/API/pkg_build/boost_1_60_0/libs/thread/src/pthread/thread.cpp:185 #6 0x00000001035679f9 in _pthread_body () #7 0x0000000103567976 in _pthread_start () #8 0x0000000103564fbd in thread_start ()
So, the thread appears to have completed any work it was doing. The problem is not reproducible 100% of the time; but when it happens (which is not infrequent), I appear to see one assertion for each detached thread that is still present during static destruction.
Change History (5)
comment:1 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 7 years ago
I suspect the change
https://github.com/boostorg/thread/commit/242cf35c519fc886c13789f1f9a049571fde4cdc
could be the cause. Please, could you try to rollback this one first?
comment:3 by , 7 years ago
Milestone: | To Be Determined → Boost 1.61.0 |
---|
comment:4 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:5 by , 7 years ago
Hi,
I wanted to investigate a bit on this bug, do you have a minimal example? I tried to produce one with the description of the bug and wrote this:
#include <boost/thread.hpp> #include <thread> #include <unistd.h> boost::thread_specific_ptr<int> p; int main() { std::thread th([]{ p.reset(new int); usleep(200000); }); //th.join(); th.detach(); pthread_exit(0); }
But this program works fine on my Linux, even if I comment the pthread_exit or if I invert the reset() and the usleep() calls.
Hi, next follows the changes applied in 1.60 that could concern this issue https://github.com/boostorg/thread/commits/develop/src/pthread/thread.cpp
https://github.com/boostorg/thread/commit/c0fe04ecc99f3ab71eaed6bcb3c5ffa77fbaa7ef https://github.com/boostorg/thread/commit/40b3dc0c2c3d781ac07433064ffc466fa96bbe2b https://github.com/boostorg/thread/commit/242cf35c519fc886c13789f1f9a049571fde4cdc https://github.com/boostorg/thread/commit/4d45da6c06970b54387ee040e20a8a88c84c50c0
There are not too much changes. Could please, try to rollback those changes and see if you get yet the issue.
I will continue to analyze it.