emulating tls for systems without

Paolo Carlini pcarlini@suse.de
Sat Oct 7 07:12:00 GMT 2006


Jakub Jelinek wrote:

>On Fri, Oct 06, 2006 at 04:17:00PM -0700, Geoffrey Keating wrote:
>  
>
>>(The big benefit of the non-emulated TLS is that memory is allocated  
>>on pthread_create(), so you know that either memory gets allocated or  
>>the thread doesn't get created, and either way you don't get random  
>>crashes...)
>>    
>>
>That's actually only true for the local-exec and initial-exec tls
>models, global-dynamic and local-dynamic tls models do sometimes
>allocate memory on the first access and can abort the process
>the same way as emutls does.
>
>So, if libstdc++-v3 relies on no allocations being done on __thread
>var access, it needs to use __attribute__((tls_model ("initial-exec"))),
>at least on Linux or wherever else is initial-exec model allowed
>even for dlopened shared libraries (though, it shouldn't really use more
>than 8 or worst case 16 bytes there, the space for these in dlopened
>libraries is quite limited).
>  
>
Jakub, thanks a lot for those additional details. I hope to look a bit 
more into these issues myself, starting from your indications, maybe you 
can also browse a bit libsupc++/eh_globals.cc and look at the 
get_globals functions?!? Note that the involved __thread var is local 
static in our case.

Paolo.



More information about the Gcc-patches mailing list