[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
Wed Apr 12 12:15:55 PDT 2017
fjricci updated this revision to Diff 95016.
fjricci added a comment.
Fix typo
https://reviews.llvm.org/D31883
Files:
lib/lsan/lsan_interceptors.cc
lib/sanitizer_common/sanitizer_posix.h
lib/sanitizer_common/sanitizer_posix_libcdep.cc
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
@@ -46,13 +46,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
@@ -928,8 +921,7 @@
ThreadIgnoreEnd(thr, pc);
}
if (res == 0) {
- int tid = ThreadCreate(thr, pc, *(uptr*)th,
- detached == PTHREAD_CREATE_DETACHED);
+ int tid = ThreadCreate(thr, pc, *(uptr*)th, IsStateDetached(detached));
CHECK_NE(tid, 0);
// Synchronization on p.tid serves two purposes:
// 1. ThreadCreate must finish before the new thread starts.
Index: lib/sanitizer_common/sanitizer_posix_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_posix_libcdep.cc
+++ lib/sanitizer_common/sanitizer_posix_libcdep.cc
@@ -418,6 +418,10 @@
return process_status;
}
+bool IsStateDetached(int state) {
+ return state == PTHREAD_CREATE_DETACHED;
+}
+
} // namespace __sanitizer
#endif // SANITIZER_POSIX
Index: lib/sanitizer_common/sanitizer_posix.h
===================================================================
--- lib/sanitizer_common/sanitizer_posix.h
+++ lib/sanitizer_common/sanitizer_posix.h
@@ -87,6 +87,9 @@
uptr internal_execve(const char *filename, char *const argv[],
char *const envp[]);
+
+bool IsStateDetached(int state);
+
} // namespace __sanitizer
#endif // SANITIZER_POSIX_H
Index: lib/lsan/lsan_interceptors.cc
===================================================================
--- lib/lsan/lsan_interceptors.cc
+++ lib/lsan/lsan_interceptors.cc
@@ -29,6 +29,10 @@
#include <stddef.h>
+#if SANITIZER_POSIX
+#include "sanitizer_common/sanitizer_posix.h"
+#endif
+
using namespace __lsan;
extern "C" {
@@ -281,7 +285,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,
+ IsStateDetached(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.95016.patch
Type: text/x-patch
Size: 2469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170412/a02213f4/attachment.bin>
More information about the llvm-commits
mailing list