Partially revert "[NFC][msan] Split ThreadStart and Init"
authorVitaly Buka <vitalybuka@google.com>
Tue, 9 Nov 2021 03:12:56 +0000 (19:12 -0800)
committerVitaly Buka <vitalybuka@google.com>
Tue, 9 Nov 2021 03:16:55 +0000 (19:16 -0800)
I don't know if removing "if (!start_routine_)" from ThreadStart
is NFC.

This reverts commit b3267bb3afd3c70a415ae81c855462affae92f6b.

compiler-rt/lib/msan/msan_thread.cpp

index 3bd34e2..40ad6a5 100644 (file)
@@ -65,7 +65,18 @@ void MsanThread::Destroy() {
   DTLS_Destroy();
 }
 
-thread_return_t MsanThread::ThreadStart() { return start_routine_(arg_); }
+thread_return_t MsanThread::ThreadStart() {
+  if (!start_routine_) {
+    // start_routine_ == 0 if we're on the main thread or on one of the
+    // OS X libdispatch worker threads. But nobody is supposed to call
+    // ThreadStart() for the worker threads.
+    return 0;
+  }
+
+  thread_return_t res = start_routine_(arg_);
+
+  return res;
+}
 
 MsanThread::StackBounds MsanThread::GetStackBounds() const {
   if (!stack_switching_)