Boost logo

Boost :

From: Schalk_Cronje_at_[hidden]
Date: 2005-02-23 08:01:16


We have encountered a Boost TSS crash when used under the following
circumstances with VC6:

* Main program dynamically loads DLLs via LoadLibrary.
* The main program does not use TSS at all.
* TSS is used by the components as class variables.
* Main program explicitly unloads DLLs before exiting
* Data in TSS is reset long before the unload occurs.

The issue seems to be related to the fact that the final cleanup handler
kicks in after the DLLs have already unloaded. I hope I have not missed
something from the archives related to such an issue.

The following diff show the changes made to fix this problem:

--- boost/libs/thread/src/tss.cpp 2005-01-07 13:01:27.000000000
+0000
+++ tss.cpp 2005-02-23 12:11:38.000000000 +0000
@@ -52,10 +52,14 @@
     tss_slots* slots = static_cast<tss_slots*>(p);
     for (tss_slots::size_type i = 0; i < slots->size(); ++i)
     {
- boost::mutex::scoped_lock lock(tss_data->mutex);
- (*tss_data->cleanup_handlers[i])((*slots)[i]);
- (*slots)[i] = 0;
+ if ((*slots)[i])
+ {
+ boost::mutex::scoped_lock lock(tss_data->mutex);
+ (*tss_data->cleanup_handlers[i])((*slots)[i]);
+ (*slots)[i] = 0;
+ }
     }
+ // delete slots; // Should we be deleting the slot data as well,
when the thread exits?
 }
 
 void init_tss_data()

The above diff also contains one line that is currently commented.
Should we delete the tss_slots instance for the specific thread?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk