Index: thread.cpp =================================================================== --- thread.cpp (revision 53346) +++ thread.cpp (working copy) @@ -24,8 +24,11 @@ #include "timeconv.inl" +#include + namespace boost { + detail::thread_data_base* main_thread_data=0; namespace detail { thread_data_base::~thread_data_base() @@ -94,6 +97,11 @@ thread_info->self.reset(); } } + void main_tls_destructor(void) { + if (main_thread_data!=0) + tls_destructor(main_thread_data); + } + } @@ -169,6 +177,9 @@ detail::thread_data_base* const me(new externally_launched_thread()); me->self.reset(me); set_current_thread_data(me); + main_thread_data=me; + BOOST_VERIFY(!atexit(&detail::main_tls_destructor)); + return me; }