HomePhabricator

[tsan] Store the pointer to ThreadState in TLS slot on Android.

Description

[tsan] Store the pointer to ThreadState in TLS slot on Android.

Summary:

  1. Android doesn't support __thread keyword. So allocate ThreadState

dynamically and store its pointer in one TLS slot provided by Android.

  1. On Android, intercepted functions can be called before ThreadState

is initialized. So add test of thr_->is_inited in some places.

  1. On Android, intercepted functions can be called after ThreadState

is destroyed. So add a fake dead_thread_state to represent all
destroyed ThreadStates. And that is also why we don't store the pointer
to ThreadState in shadow memory of pthread_self().

Reviewers: kcc, eugenis, dvyukov

Subscribers: kubabrecka, llvm-commits, tberghammer, danalbert, srhines

Differential Revision: http://reviews.llvm.org/D15301

Details