diff options
author | Kuba Brecka <kuba.brecka@gmail.com> | 2016-05-02 15:06:08 +0000 |
---|---|---|
committer | Kuba Brecka <kuba.brecka@gmail.com> | 2016-05-02 15:06:08 +0000 |
commit | 4e704facb41037e14f8f51332b839accabf3b016 (patch) | |
tree | dec27d1d8b9c5f5e24f76db90395d1408508f9ba /lib/sanitizer_common/sanitizer_thread_registry.cc | |
parent | 6d7e49d4d2f31a605745e436305eac8a29536b3d (diff) |
[sanitizer] Don't reuse the main thread in ThreadRegistry
There is a hard-to-reproduce crash happening on OS X that involves terminating the main thread (dispatch_main does that, see discussion at http://reviews.llvm.org/D18496) and later reusing the main thread's ThreadContext. This patch disables reuse of the main thread. I believe this problem exists only on OS X, because on other systems the main thread cannot be terminated without exiting the process.
Differential Revision: http://reviews.llvm.org/D19722
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268238 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_thread_registry.cc')
-rw-r--r-- | lib/sanitizer_common/sanitizer_thread_registry.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_thread_registry.cc b/lib/sanitizer_common/sanitizer_thread_registry.cc index 2ec92ffd3..6e7ddfa64 100644 --- a/lib/sanitizer_common/sanitizer_thread_registry.cc +++ b/lib/sanitizer_common/sanitizer_thread_registry.cc @@ -277,6 +277,8 @@ void ThreadRegistry::StartThread(u32 tid, uptr os_id, void *arg) { } void ThreadRegistry::QuarantinePush(ThreadContextBase *tctx) { + if (tctx->tid == 0) + return; // Don't reuse the main thread. It's a special snowflake. dead_threads_.push_back(tctx); if (dead_threads_.size() <= thread_quarantine_size_) return; |