Boost C++ Libraries: Ticket #5837: tss_dll: does not appear to allocate TLS storage at the proper time https://svn.boost.org/trac10/ticket/5837 <p> When a Windows process loads a DLL, <a class="missing wiki">DllMain</a> will recieve DLL_PROCESS_ATTACH. According to MSDN process can use the opportunity to allocate thread storage <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a>. Interestingly, on_process_enter() (and on_thread_enter()) does not perform the initialization. Note that on_process_enter() is the Boost routine for DLL_PROCESS_ATTACH; and on_thread_enter() is called for DLL_THREAD_ATTACH. </p> <p> From tss_hooks.cpp: </p> <pre class="wiki">extern "C" BOOST_THREAD_DECL void on_process_enter() { } </pre><p> and </p> <pre class="wiki">extern "C" BOOST_THREAD_DECL void on_thread_enter() { } </pre><p> Even more bizarre, on_thread_exit() appears to allocate the thread local storage: </p> <pre class="wiki">extern "C" BOOST_THREAD_DECL void on_thread_exit() { // Initializing tls_key here ensures its proper visibility boost::call_once( init_tls_key, once_init_tls_key ); // Get the exit handlers list for the current thread from tls. if( tls_key == invalid_tls_key ) { return; } ... </pre><p> Perhaps it would be a good idea to review the MSDN documentation, and perfom TLS initialization according to Microsoft recommendations. </p> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a> <a class="ext-link" href="http://msdn.microsoft.com/en-us/library/ms682583(v=vs.85).aspx"><span class="icon">​</span>http://msdn.microsoft.com/en-us/library/ms682583(v=vs.85).aspx</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5837 Trac 1.4.3 Jeffrey Walton <noloader@…> Wed, 31 Aug 2011 00:43:24 GMT component changed; cc, owner set https://svn.boost.org/trac10/ticket/5837#comment:1 https://svn.boost.org/trac10/ticket/5837#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">noloader@…</span> added </li> <li><strong>owner</strong> set to <span class="trac-author">Anthony Williams</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">thread</span> </li> </ul> Ticket viboes Sun, 11 Dec 2011 11:29:49 GMT keywords set https://svn.boost.org/trac10/ticket/5837#comment:2 https://svn.boost.org/trac10/ticket/5837#comment:2 <ul> <li><strong>keywords</strong> tss added </li> </ul> Ticket viboes Thu, 29 Dec 2011 14:24:07 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5837#comment:3 https://svn.boost.org/trac10/ticket/5837#comment:3 <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">invalid</span> </li> </ul> <p> Closed as the file tss_hooks.cpp doesn't exists </p> <p> The current code is </p> <pre class="wiki"> BOOST_THREAD_DECL void __cdecl on_process_enter() {} BOOST_THREAD_DECL void __cdecl on_thread_enter() {} BOOST_THREAD_DECL void __cdecl on_process_exit() { boost::cleanup_tls_key(); } BOOST_THREAD_DECL void __cdecl on_thread_exit() { boost::run_thread_exit_callbacks(); } </pre> Ticket