[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
Tue Apr 11 11:27:31 PDT 2017
fjricci updated this revision to Diff 94866.
fjricci added a comment.
Address comments
https://reviews.llvm.org/D31883
Files:
lib/lsan/lsan_interceptors.cc
lib/sanitizer_common/sanitizer_linux.h
lib/sanitizer_common/sanitizer_mac.h
lib/tsan/rtl/tsan_interceptors.cc
Index: lib/tsan/rtl/tsan_interceptors.cc
===================================================================
--- lib/tsan/rtl/tsan_interceptors.cc
+++ lib/tsan/rtl/tsan_interceptors.cc
@@ -16,6 +16,7 @@
#include "sanitizer_common/sanitizer_atomic.h"
#include "sanitizer_common/sanitizer_libc.h"
#include "sanitizer_common/sanitizer_linux.h"
+#include "sanitizer_common/sanitizer_mac.h"
#include "sanitizer_common/sanitizer_platform_limits_posix.h"
#include "sanitizer_common/sanitizer_placement_new.h"
#include "sanitizer_common/sanitizer_stacktrace.h"
@@ -46,13 +47,6 @@
#define mallopt(a, b)
#endif
-#if SANITIZER_LINUX || SANITIZER_FREEBSD
-#define PTHREAD_CREATE_DETACHED 1
-#elif SANITIZER_MAC
-#define PTHREAD_CREATE_DETACHED 2
-#endif
-
-
#ifdef __mips__
const int kSigCount = 129;
#else
@@ -911,7 +905,7 @@
pthread_attr_init(&myattr);
attr = &myattr;
}
- int detached = 0;
+ int detached = PTHREAD_CREATE_JOINABLE;
REAL(pthread_attr_getdetachstate)(attr, &detached);
AdjustStackSize(attr);
Index: lib/sanitizer_common/sanitizer_mac.h
===================================================================
--- lib/sanitizer_common/sanitizer_mac.h
+++ lib/sanitizer_common/sanitizer_mac.h
@@ -38,6 +38,9 @@
} // namespace __sanitizer
+#define PTHREAD_CREATE_JOINABLE 1
+#define PTHREAD_CREATE_DETACHED 2
+
extern "C" {
static char __crashreporter_info_buff__[__sanitizer::kErrorMessageBufferSize] =
{};
Index: lib/sanitizer_common/sanitizer_linux.h
===================================================================
--- lib/sanitizer_common/sanitizer_linux.h
+++ lib/sanitizer_common/sanitizer_linux.h
@@ -54,6 +54,9 @@
#endif
#endif // SANITIZER_LINUX
+#define PTHREAD_CREATE_JOINABLE 0
+#define PTHREAD_CREATE_DETACHED 1
+
// This class reads thread IDs from /proc/<pid>/task using only syscalls.
class ThreadLister {
public:
Index: lib/lsan/lsan_interceptors.cc
===================================================================
--- lib/lsan/lsan_interceptors.cc
+++ lib/lsan/lsan_interceptors.cc
@@ -19,6 +19,7 @@
#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_linux.h"
+#include "sanitizer_common/sanitizer_mac.h"
#include "sanitizer_common/sanitizer_platform_interceptors.h"
#include "sanitizer_common/sanitizer_platform_limits_posix.h"
#include "sanitizer_common/sanitizer_tls_get_addr.h"
@@ -274,7 +275,7 @@
attr = &myattr;
}
AdjustStackSize(attr);
- int detached = 0;
+ int detached = PTHREAD_CREATE_JOINABLE;
pthread_attr_getdetachstate(attr, &detached);
ThreadParam p;
p.callback = callback;
@@ -290,7 +291,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.94866.patch
Type: text/x-patch
Size: 3135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170411/018c012f/attachment.bin>
More information about the llvm-commits
mailing list