[cxx-abi-dev] thread_local destructors

Dennis Handly dhandly at cup.hp.com
Sat Sep 22 04:42:08 UTC 2012


>From: Jason Merrill <jason at redhat.com>
>> do we need a __cxa_finalize_thread function?

>I've been experimenting with registering a 
>private finalize function as a pthread_key_create destructor;

I guess its name is __cxa_finalize_thread.  :-)

>except that they don't get run for the main thread 
>unless it explicitly calls pthread_exit.

And how to handle that?

>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.

Nothing about pthread_exit or pthread_cancel.
For the former, you get it.  For the latter, is that like _exit where you
don't want to run them.

Also, for the case of std::exit, would that have to sit on top of exit and
do more work?

I think for HP-UX, only one thread gets into exit, the rest are blocked if
they try.

>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.

This would mean std::exit would have to kill all of the threads first?

>But this is an internal detail that doesn't need to be part of the ABI.

Ok, I thought we would need trickiness where we would need exposition.

>From: Jason Merrill <jason at redhat.com>
>> That would be more user-friendly, yes.

>Another possibility would be to lock affected shlibs in memory, such as 
>with the glibc RTLD_NODELETE flag to dlopen.

Ok.  This is a user requirement?  Or we somehow "add" RTLD_NODELETE to
the loaded shlib?


More information about the cxx-abi-dev mailing list