Hi,

I would like to highlight an issue related to calling functions that
create application specific TLS keys from within functions marked as
__attribute__ ((constructor)).

For e.g. consider the following routine:

static void __attribute__ ((constructor)) foo(void)
{
  ...
        pthread_key_create(..);
  ...
}

bionic/linker/linker.c:__linker_init() calls foo() and the
pthread_key_create() would use the temporary TLS bionic/linker/
linker.c:__tls_area which is OK, until the main thread's TLS is
initialized in bionic/libc/bionic/libc_init_common.c and thus the key
created in the old TLS is no longer accessible resulting in the app
segfaulting.

This situation actually occurs when trying to port the gcc OpenMP
runtime. Although for the moment, I've worked around the problem among
others and am able to successfully execute OpenMP apps under Android.

In fact, I've seen a commit
http://android.git.kernel.org/?p=platform/bionic.git;a=commit;h=03eabfe65e1e2c36f4d26c78a730fa19a3bdada3
which, by re-using the temporary TLS for the main thread would
actually fix the problem I've described but I noticed that this commit
has been reverted and a different solution was committed later.

Cheers,
surinder

--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting
-~----------~----~----~----~------~----~------~--~---

Reply via email to