[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

llvm-svn: 268238
This commit is contained in:
Kuba Brecka 2016-05-02 15:06:08 +00:00
parent e5e04baf95
commit d052a57900
1 changed files with 2 additions and 0 deletions

View File

@ -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;