[compiler-rt] 914d082 - [lsan] Fix Darwin build

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 17 16:30:06 PDT 2023


Author: Vitaly Buka
Date: 2023-04-17T16:29:55-07:00
New Revision: 914d082ff0beec08f8b8ceafcf04fb357b4899c5

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

LOG: [lsan] Fix Darwin build

Added: 
    

Modified: 
    compiler-rt/lib/lsan/lsan_common_mac.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/lsan/lsan_common_mac.cpp b/compiler-rt/lib/lsan/lsan_common_mac.cpp
index 70ff6d57ad79..79cc987b3a0c 100644
--- a/compiler-rt/lib/lsan/lsan_common_mac.cpp
+++ b/compiler-rt/lib/lsan/lsan_common_mac.cpp
@@ -25,6 +25,8 @@
 #  include "sanitizer_common/sanitizer_allocator_internal.h"
 namespace __lsan {
 
+class ThreadContextLsanBase;
+
 enum class SeenRegion {
   None = 0,
   AllocOnce = 1 << 0,
@@ -57,11 +59,11 @@ typedef struct {
 static pthread_key_t key;
 static pthread_once_t key_once = PTHREAD_ONCE_INIT;
 
-// The main thread destructor requires the current thread id,
-// so we can't destroy it until it's been used and reset to invalid tid
+// The main thread destructor requires the current thread,
+// so we can't destroy it until it's been used and reset.
 void restore_tid_data(void *ptr) {
   thread_local_data_t *data = (thread_local_data_t *)ptr;
-  if (data->current_thread_id != kInvalidTid)
+  if (data->current_thread_id)
     pthread_setspecific(key, data);
 }
 
@@ -76,7 +78,7 @@ static thread_local_data_t *get_tls_val(bool alloc) {
   if (ptr == NULL && alloc) {
     ptr = (thread_local_data_t *)InternalAlloc(sizeof(*ptr));
     ptr->disable_counter = 0;
-    ptr->current_thread_id = kInvalidTid;
+    ptr->current_thread = nullptr;
     ptr->cache = AllocatorCache();
     pthread_setspecific(key, ptr);
   }


        


More information about the llvm-commits mailing list