Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66471 - trunk/libs/thread/src/win32
From: anthony_at_[hidden]
Date: 2010-11-09 07:54:25


Author: anthonyw
Date: 2010-11-09 07:54:23 EST (Tue, 09 Nov 2010)
New Revision: 66471
URL: http://svn.boost.org/trac/boost/changeset/66471

Log:
fix for issue #4736 --- avoid setting tls data after the key has been destroyed
Text files modified:
   trunk/libs/thread/src/win32/thread.cpp | 16 +++++++++++-----
   1 files changed, 11 insertions(+), 5 deletions(-)

Modified: trunk/libs/thread/src/win32/thread.cpp
==============================================================================
--- trunk/libs/thread/src/win32/thread.cpp (original)
+++ trunk/libs/thread/src/win32/thread.cpp 2010-11-09 07:54:23 EST (Tue, 09 Nov 2010)
@@ -56,7 +56,8 @@
         void set_current_thread_data(detail::thread_data_base* new_data)
         {
             boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
- BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data));
+ if(current_thread_tls_key)
+ BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data));
         }
 
 #ifdef BOOST_NO_THREADEX
@@ -226,6 +227,10 @@
 
         detail::thread_data_base* get_or_make_current_thread_data()
         {
+ if(!current_thread_tls_key)
+ {
+ throw thread_resource_error();
+ }
             detail::thread_data_base* current_thread_data(get_current_thread_data());
             if(!current_thread_data)
             {
@@ -540,8 +545,8 @@
         {
             detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
             thread_exit_callback_node* const new_node=
- heap_new<thread_exit_callback_node>(func,
- current_thread_data->thread_exit_callbacks);
+ heap_new<thread_exit_callback_node>(
+ func,current_thread_data->thread_exit_callbacks);
             current_thread_data->thread_exit_callbacks=new_node;
         }
 
@@ -583,10 +588,11 @@
                 current_node->func=func;
                 current_node->value=tss_data;
             }
- else
+ else if(func && tss_data)
             {
                 detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
- tss_data_node* const new_node=heap_new<tss_data_node>(key,func,tss_data,current_thread_data->tss_data);
+ tss_data_node* const new_node=
+ heap_new<tss_data_node>(key,func,tss_data,current_thread_data->tss_data);
                 current_thread_data->tss_data=new_node;
             }
         }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk