[compiler-rt] b986343 - [NFC] Remove Win specific Destroy from ThreadStart

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 25 15:02:51 PDT 2023


Author: Vitaly Buka
Date: 2023-07-25T15:02:42-07:00
New Revision: b9863430ec2cf5320320f8aae91d7040d47c099a

URL: https://github.com/llvm/llvm-project/commit/b9863430ec2cf5320320f8aae91d7040d47c099a
DIFF: https://github.com/llvm/llvm-project/commit/b9863430ec2cf5320320f8aae91d7040d47c099a.diff

LOG: [NFC] Remove Win specific Destroy from ThreadStart

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_thread.cpp
    compiler-rt/lib/asan/asan_win.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_thread.cpp b/compiler-rt/lib/asan/asan_thread.cpp
index f718adf5e1f73c..ba0ddddc338c4f 100644
--- a/compiler-rt/lib/asan/asan_thread.cpp
+++ b/compiler-rt/lib/asan/asan_thread.cpp
@@ -288,17 +288,7 @@ thread_return_t AsanThread::ThreadStart(tid_t os_id) {
     return 0;
   }
 
-  thread_return_t res = start_routine_(arg_);
-
-  // On POSIX systems we defer this to the TSD destructor. LSan will consider
-  // the thread's memory as non-live from the moment we call Destroy(), even
-  // though that memory might contain pointers to heap objects which will be
-  // cleaned up by a user-defined TSD destructor. Thus, calling Destroy() before
-  // the TSD destructors have run might cause false positives in LSan.
-  if (!SANITIZER_POSIX)
-    this->Destroy();
-
-  return res;
+  return start_routine_(arg_);
 }
 
 AsanThread *CreateMainThread() {

diff  --git a/compiler-rt/lib/asan/asan_win.cpp b/compiler-rt/lib/asan/asan_win.cpp
index 25f2e6cd551fea..feb3a2dcd12a62 100644
--- a/compiler-rt/lib/asan/asan_win.cpp
+++ b/compiler-rt/lib/asan/asan_win.cpp
@@ -134,7 +134,9 @@ INTERCEPTOR(int, _except_handler4, void *a, void *b, void *c, void *d) {
 static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
   AsanThread *t = (AsanThread *)arg;
   SetCurrentThread(t);
-  return t->ThreadStart(GetTid());
+  auto res = t->ThreadStart(GetTid());
+  t->Destroy();  // POSIX calls this from TSD destructor.
+  return rest;
 }
 
 INTERCEPTOR_WINAPI(HANDLE, CreateThread, LPSECURITY_ATTRIBUTES security,


        


More information about the llvm-commits mailing list