[PATCH] D19722: [sanitizer] Don't reuse the main thread in ThreadRegistry

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 06:49:27 PDT 2016


kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, samsonov, glider, kcc.
kubabrecka added subscribers: llvm-commits, zaks.anna, dcoughlin.
kubabrecka added a project: Sanitizers.
Herald added a subscriber: kubabrecka.

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.

http://reviews.llvm.org/D19722

Files:
  lib/sanitizer_common/sanitizer_thread_registry.cc

Index: lib/sanitizer_common/sanitizer_thread_registry.cc
===================================================================
--- lib/sanitizer_common/sanitizer_thread_registry.cc
+++ lib/sanitizer_common/sanitizer_thread_registry.cc
@@ -277,6 +277,8 @@
 }
 
 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19722.55591.patch
Type: text/x-patch
Size: 521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160429/1df45b51/attachment.bin>


More information about the llvm-commits mailing list