diff options
author | Yabin Cui <yabinc@google.com> | 2015-11-24 17:24:06 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2015-11-24 17:24:06 -0800 |
commit | 952e9eb0866bc2061b671e8d6c90cae275eda6bd (patch) | |
tree | 1a6fd63119783ddb62d9faaec1e57489b707fc18 /libc/stdio/stdio_ext.cpp | |
parent | 8bd27182c505cdc8031ab23fea5d1dccb6b7405a (diff) |
Don't use __thread in __cxa_thread_finalize().
Currently we use __thread variable to store thread_local_dtors,
which makes tsan test fork_atexit.cc hang. The problem is as below:
The main thread creates a worker thread, the worker thread calls
pthread_exit() -> __cxa_thread_finalize() -> __emutls_get_address()
-> pthread_once(emutls_init) -> emutls_init().
Then the main thread calls fork(), the child process cals
exit() -> __cxa_thread_finalize() -> __emutls_get_address()
-> pthread_once(emutls_init).
So the child process is waiting for pthread_once(emutls_init)
to finish which will never occur.
It might be the test's fault because POSIX standard says if a
multi-threaded process calls fork(), the new process may only
execute async-signal-safe operations until exec functions are
called. And exit() is not async-signal-safe. But we can make
bionic more reliable by not using __thread in
__cxa_thread_finalize().
Bug: 25392375
Change-Id: Ife403dd7379dad8ddf1859c348c1c0adea07afb3
Diffstat (limited to 'libc/stdio/stdio_ext.cpp')
0 files changed, 0 insertions, 0 deletions