[cxx-abi-dev] thread_local destructors

Jason Merrill jason at redhat.com
Thu Sep 20 14:53:00 UTC 2012


C++11 specifies that thread_local variables can have dynamic 
initialization and destruction semantics, so we need to add that to the 
existing TLS model.  As discussed in N2659 it is possible to support 
dynamic initialization in just the compiler, but for destruction we need 
a thread-local version of atexit.  This seems to call for a new runtime 
entry point __cxa_thread_atexit.

The question is, do we want to try to deal with the intersection of 
threads and shared libraries?  If the user dlcloses a library with TLS 
objects that have destructors in multiple threads, trying to arrange for 
the affected threads to run the relevant destructors seems
complex.  Are other people comfortable just saying "don't do that"?

Jason


More information about the cxx-abi-dev mailing list