浏览代码

xplat: pthread_exit call needed to free TLS

Thread-local storage for pthreads don't get destructor calls unless
pthread_exit is called from their thread; this happens implicitly in
non-main threads, but needs to be explicitly done in main.

Only doing this in ASAN builds, as it causes issues with OSX pthread
implementations.
Derek Morris 8 年之前
父节点
当前提交
e57b45783a
共有 3 个文件被更改,包括 11 次插入2 次删除
  1. 8 0
      bin/ch/ch.cpp
  2. 1 1
      lib/Common/CommonDefines.h
  3. 2 1
      lib/Common/DataStructures/FixedBitVector.h

+ 8 - 0
bin/ch/ch.cpp

@@ -8,6 +8,8 @@
 #include <winver.h>
 #include <winver.h>
 #include <process.h>
 #include <process.h>
 #include <fcntl.h>
 #include <fcntl.h>
+#else
+#include <pthread.h>
 #endif
 #endif
 
 
 #ifdef __linux__
 #ifdef __linux__
@@ -1154,6 +1156,12 @@ return_cleanup:
     }
     }
     delete[] argv;
     delete[] argv;
     argv = nullptr;
     argv = nullptr;
+#ifdef NO_SANITIZE_ADDRESS_CHECK
+    pthread_exit(&retval);
+#else
+    return retval;
 #endif
 #endif
+#else
     return retval;
     return retval;
+#endif
 }
 }

+ 1 - 1
lib/Common/CommonDefines.h

@@ -686,7 +686,7 @@
 #if __has_feature(address_sanitizer)
 #if __has_feature(address_sanitizer)
 #undef NO_SANITIZE_ADDRESS
 #undef NO_SANITIZE_ADDRESS
 #define NO_SANITIZE_ADDRESS __attribute__((no_sanitize("address")))
 #define NO_SANITIZE_ADDRESS __attribute__((no_sanitize("address")))
-#define NO_SANITIZE_ADDRESS_FIXVC
+#define NO_SANITIZE_ADDRESS_CHECK
 #endif
 #endif
 #endif
 #endif
 
 

+ 2 - 1
lib/Common/DataStructures/FixedBitVector.h

@@ -226,8 +226,9 @@ Container BVFixed::GetRange(BVIndex start, BVIndex len) const
     return Container(range);
     return Container(range);
 }
 }
 
 
+// the NO_SANITIZE_ADDRESS_CHECK ifdef is to work around a bug in some VC versions
 template<typename Container>
 template<typename Container>
-#ifdef NO_SANITIZE_ADDRESS_FIXVC
+#ifdef NO_SANITIZE_ADDRESS_CHECK
 NO_SANITIZE_ADDRESS
 NO_SANITIZE_ADDRESS
 #endif
 #endif
 void BVFixed::SetRange(Container* value, BVIndex start, BVIndex len)
 void BVFixed::SetRange(Container* value, BVIndex start, BVIndex len)