[cxx-abi-dev] thread_local destructors

Jason Merrill jason at redhat.com
Fri Sep 21 13:08:47 UTC 2012


On 09/20/2012 06:26 PM, Dennis Handly wrote:
> Also, do we need a __cxa_finalize_thread function?

That's not clear to me.  I've been experimenting with registering a 
private finalize function as a pthread_key_create destructor; it seems 
to work pretty well except that they don't get run for the main thread 
unless it explicitly calls pthread_exit.

> And what happen when exit is called?  All existing object destroyed in order?

3.6.3:

Destructors for initialized objects with thread storage duration within 
a given thread are called as a result of returning from the initial 
function of that thread and as a result of that thread calling 
std::exit. The completions of the destructors for all initialized 
objects with thread storage duration within that thread are sequenced
before the initiation of the destructors of any object with static 
storage duration.

> Do we need a new data structure that will have:
>     address
>     dtor
>     __dso_handle
>     thread_id
>     next

The data structure can itself be thread_local, so we don't need to store 
the thread_id.  But this is an internal detail that doesn't need to be 
part of the ABI.

> Would one of the "don't do that" responses be to at least dump a list of
> all of the TLS objects (addresses of object and dtor and the shlib KEY) that
> are affected, before aborting?

That would be more user-friendly, yes.

Jason



More information about the cxx-abi-dev mailing list