[PATCH] D31883: Don't assume PTHREAD_CREATE_JOINABLE is 0 on all systems
Francis Ricci via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 11:05:05 PDT 2017
fjricci created this revision.
Lsan was using PTHREAD_CREATE_JOINABLE/PTHREAD_CREATE_DETACHED
as truthy values, which works on Linux, where the values are 0 and 1,
but this fails on OS X, where the values are 1 and 2.
Set PTHREAD_CREATE_DETACHED to the correct value for a given system.
https://reviews.llvm.org/D31883
Files:
lib/lsan/lsan_interceptors.cc
Index: lib/lsan/lsan_interceptors.cc
===================================================================
--- lib/lsan/lsan_interceptors.cc
+++ lib/lsan/lsan_interceptors.cc
@@ -53,6 +53,12 @@
struct nothrow_t;
}
+#if SANITIZER_LINUX || SANITIZER_FREEBSD
+#define PTHREAD_CREATE_DETACHED 1
+#elif SANITIZER_MAC
+#define PTHREAD_CREATE_DETACHED 2
+#endif
+
INTERCEPTOR(void*, malloc, uptr size) {
ENSURE_LSAN_INITED;
GET_STACK_TRACE_MALLOC;
@@ -290,7 +296,8 @@
res = REAL(pthread_create)(th, attr, __lsan_thread_start_func, &p);
}
if (res == 0) {
- int tid = ThreadCreate(GetCurrentThread(), *(uptr *)th, detached);
+ int tid = ThreadCreate(GetCurrentThread(), *(uptr *)th,
+ detached == PTHREAD_CREATE_DETACHED);
CHECK_NE(tid, 0);
atomic_store(&p.tid, tid, memory_order_release);
while (atomic_load(&p.tid, memory_order_acquire) != 0)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31883.94668.patch
Type: text/x-patch
Size: 905 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170410/707ff3ab/attachment.bin>
More information about the llvm-commits
mailing list