Boost C++ Libraries: Ticket #11053: The attached code results in a R6025 - pure virtual function call in run_thread_exit_callbacks https://svn.boost.org/trac10/ticket/11053 <p> Caused when deallocating a thread specific pointer in a object that is inside thread specific data. I suggest changing the code in run_thread_exit_callbacks from </p> <pre class="wiki">for(std::map&lt;void const*,detail::tss_data_node&gt;::iterator next=current_thread_data-&gt;tss_data.begin(), current, end=current_thread_data-&gt;tss_data.end(); next!=end;) { current=next; ++next; if(current-&gt;second.func &amp;&amp; (current-&gt;second.value!=0)) { (*current-&gt;second.func)(current-&gt;second.value); } current_thread_data-&gt;tss_data.erase(current); } </pre><p> to </p> <pre class="wiki">while (!current_thread_data-&gt;tss_data.empty()) { std::map&lt;void const*,detail::tss_data_node&gt;::iterator current = current_thread_data-&gt;tss_data.begin(); if(current-&gt;second.func &amp;&amp; (current-&gt;second.value!=0)) { (*current-&gt;second.func)(current-&gt;second.value); } current_thread_data-&gt;tss_data.erase(current); } </pre><p> Code to reproduce the problem: </p> <pre class="wiki">#include &lt;boost/thread.hpp&gt; #include &lt;boost/thread/tss.hpp&gt; #include &lt;boost/shared_ptr.hpp&gt; #include &lt;iostream&gt; struct A { void DoWork() { std::cout &lt;&lt; "A: doing work\n"; if (!m_ptr.get()) m_ptr.reset(new WorkSpace()); // do not very much for (size_t i = 0; i &lt; 10; ++i) m_ptr-&gt;a += 10; } private: struct WorkSpace { int a; WorkSpace() : a(0) {} }; boost::thread_specific_ptr&lt;WorkSpace&gt; m_ptr; }; struct B { void DoWork() { std::cout &lt;&lt; "B: doing work\n"; if (!m_ptr.get()) m_ptr.reset(new A()); m_ptr-&gt;DoWork(); } private: boost::thread_specific_ptr&lt;A&gt; m_ptr; }; struct C { void DoWork() { std::cout &lt;&lt; "C: doing work\n"; if (!m_ptr.get()) m_ptr.reset(new B()); m_ptr-&gt;DoWork(); } private: boost::thread_specific_ptr&lt;B&gt; m_ptr; }; int main(int ac, char** av) { std::cout &lt;&lt; "test starting\n"; boost::shared_ptr&lt;C&gt; p_C(new C); boost::thread cWorker(&amp;C::DoWork, p_C); cWorker.join(); std::cout &lt;&lt; "test stopping\n"; } </pre><p> Compiler visual studio 2012 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11053 Trac 1.4.3 viboes Sat, 28 Feb 2015 20:51:25 GMT owner, status changed https://svn.boost.org/trac10/ticket/11053#comment:1 https://svn.boost.org/trac10/ticket/11053#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> Thanks for catching this bug. </p> <p> It is also reproducible on POSIX platform and the code to be replaced is similar. </p> Ticket viboes Sat, 28 Feb 2015 20:53:14 GMT description changed https://svn.boost.org/trac10/ticket/11053#comment:2 https://svn.boost.org/trac10/ticket/11053#comment:2 <ul> <li><strong>description</strong> modified (<a href="/trac10/ticket/11053?action=diff&amp;version=2">diff</a>) </li> </ul> Ticket viboes Sun, 01 Mar 2015 22:21:02 GMT milestone changed https://svn.boost.org/trac10/ticket/11053#comment:3 https://svn.boost.org/trac10/ticket/11053#comment:3 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.58.0</span> </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/c678b3794b0c523750e64f26688d4d517af30e3a"><span class="icon">​</span>https://github.com/boostorg/thread/commit/c678b3794b0c523750e64f26688d4d517af30e3a</a> </p> Ticket viboes Sun, 08 Mar 2015 22:17:03 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11053#comment:4 https://svn.boost.org/trac10/ticket/11053#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