Boost C++ Libraries: Ticket #12049: Assertion failure from detached threads during shutdown https://svn.boost.org/trac10/ticket/12049 <p> I'm observing assertion failures coming from detached threads during shutdown (i.e., the main thread is in static destruction): </p> <pre class="wiki">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. </pre><p> 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. </p> <p> Stacks from these threads at the time of the assertion failure look like this: </p> <pre class="wiki">#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 () </pre><p> 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. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12049 Trac 1.4.3 viboes Sat, 19 Mar 2016 15:59:50 GMT owner, status changed https://svn.boost.org/trac10/ticket/12049#comment:1 https://svn.boost.org/trac10/ticket/12049#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Hi, next follows the changes applied in 1.60 that could concern this issue <a class="ext-link" href="https://github.com/boostorg/thread/commits/develop/src/pthread/thread.cpp"><span class="icon">​</span>https://github.com/boostorg/thread/commits/develop/src/pthread/thread.cpp</a> </p> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/c0fe04ecc99f3ab71eaed6bcb3c5ffa77fbaa7ef"><span class="icon">​</span>https://github.com/boostorg/thread/commit/c0fe04ecc99f3ab71eaed6bcb3c5ffa77fbaa7ef</a> <a class="ext-link" href="https://github.com/boostorg/thread/commit/40b3dc0c2c3d781ac07433064ffc466fa96bbe2b"><span class="icon">​</span>https://github.com/boostorg/thread/commit/40b3dc0c2c3d781ac07433064ffc466fa96bbe2b</a> <a class="ext-link" href="https://github.com/boostorg/thread/commit/242cf35c519fc886c13789f1f9a049571fde4cdc"><span class="icon">​</span>https://github.com/boostorg/thread/commit/242cf35c519fc886c13789f1f9a049571fde4cdc</a> <a class="ext-link" href="https://github.com/boostorg/thread/commit/4d45da6c06970b54387ee040e20a8a88c84c50c0"><span class="icon">​</span>https://github.com/boostorg/thread/commit/4d45da6c06970b54387ee040e20a8a88c84c50c0</a> </p> <p> There are not too much changes. Could please, try to rollback those changes and see if you get yet the issue. </p> <p> I will continue to analyze it. </p> Ticket viboes Sat, 19 Mar 2016 16:10:07 GMT <link>https://svn.boost.org/trac10/ticket/12049#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12049#comment:2</guid> <description> <p> I suspect the change </p> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/242cf35c519fc886c13789f1f9a049571fde4cdc"><span class="icon">​</span>https://github.com/boostorg/thread/commit/242cf35c519fc886c13789f1f9a049571fde4cdc</a> </p> <p> could be the cause. Please, could you try to rollback this one first? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 23 Mar 2016 22:16:40 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/12049#comment:3 https://svn.boost.org/trac10/ticket/12049#comment:3 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.61.0</span> </li> </ul> <p> rollback done with <a class="ext-link" href="https://github.com/boostorg/thread/commit/47357de276fe4fc01469f34c1dbf8b26fdbc1c4b"><span class="icon">​</span>https://github.com/boostorg/thread/commit/47357de276fe4fc01469f34c1dbf8b26fdbc1c4b</a> </p> Ticket viboes Thu, 31 Mar 2016 22:16:51 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/12049#comment:4 https://svn.boost.org/trac10/ticket/12049#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket blastrock Mon, 18 Apr 2016 07:19:33 GMT <link>https://svn.boost.org/trac10/ticket/12049#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12049#comment:5</guid> <description> <p> Hi, </p> <p> 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: </p> <pre class="wiki">#include &lt;boost/thread.hpp&gt; #include &lt;thread&gt; #include &lt;unistd.h&gt; boost::thread_specific_ptr&lt;int&gt; p; int main() { std::thread th([]{ p.reset(new int); usleep(200000); }); //th.join(); th.detach(); pthread_exit(0); } </pre><p> 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. </p> </description> <category>Ticket</category> </item> </channel> </rss>