pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

compiler-rt-netbsd: Handle ThreadExit in MSan/NetBSD



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Mon Dec 4 23:57:24 2017 +0100
Changeset:	56ebe2d0753ace577c40bc3cd39dbcaa3b2ffb30

Modified Files:
	compiler-rt-netbsd/distinfo
Added Files:
	compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc

Log Message:
compiler-rt-netbsd: Handle ThreadExit in MSan/NetBSD

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=56ebe2d0753ace577c40bc3cd39dbcaa3b2ffb30

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 compiler-rt-netbsd/distinfo                        |  1 +
 .../patches/patch-lib_msan_msan__linux.cc          | 62 ++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index ad26b9ea44..a88863f0c5 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -4,6 +4,7 @@ SHA1 (patch-cmake_config-ix.cmake) = 5068232331d541c2786f01960a80e59252b1ad2c
 SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = 38ca750154dfc9843a56748078235824b772a147
 SHA1 (patch-lib_msan_msan.h) = 1ee0f86ccb410561d381afba526c85aa5dace912
 SHA1 (patch-lib_msan_msan__interceptors.cc) = e3b4faf858e124b3ba0810f1795c8c220e3ebc23
+SHA1 (patch-lib_msan_msan__linux.cc) = d75d7587071a9e7a3f6a08a3008af55319e62cab
 SHA1 (patch-lib_scudo_scudo__platform.h) = 8970c6225630737740affd97e68a5ca8c4ec5c11
 SHA1 (patch-test_lsan_lit.common.cfg) = 10dc251f80efb96d015a22c740dc20b1843b9a11
 SHA1 (patch-test_scudo_lit.cfg) = 4e6ad680e81d3dcb6032eb367fea82eb1adfa0df
diff --git a/compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc b/compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc
new file mode 100644
index 0000000000..d927882b08
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc
@@ -0,0 +1,62 @@
+$NetBSD$
+
+--- lib/msan/msan_linux.cc.orig	2017-11-16 17:55:36.000000000 +0000
++++ lib/msan/msan_linux.cc
+@@ -30,6 +30,7 @@
+ #include <sys/time.h>
+ #include <sys/resource.h>
+ 
++#include "interception/interception.h"
+ #include "sanitizer_common/sanitizer_common.h"
+ #include "sanitizer_common/sanitizer_procmaps.h"
+ 
+@@ -174,13 +175,28 @@ void InstallAtExitHandler() {
+ 
+ // ---------------------- TSD ---------------- {{{1
+ 
++#if !SANITIZER_NETBSD
+ static pthread_key_t tsd_key;
++#endif
++
+ static bool tsd_key_inited = false;
+ 
++#if SANITIZER_NETBSD
++INTERCEPTOR(void, _lwp_exit) {
++  CHECK(tsd_key_inited);
++  MsanTSDDtor(GetCurrentThread());
++  REAL(_lwp_exit)();
++}
++#endif
++
+ void MsanTSDInit(void (*destructor)(void *tsd)) {
+   CHECK(!tsd_key_inited);
+   tsd_key_inited = true;
++#if SANITIZER_NETBSD
++  INTERCEPT_FUNCTION(_lwp_exit);
++#else
+   CHECK_EQ(0, pthread_key_create(&tsd_key, destructor));
++#endif
+ }
+ 
+ static THREADLOCAL MsanThread* msan_current_thread;
+@@ -195,16 +211,20 @@ void SetCurrentThread(MsanThread *t) {
+   msan_current_thread = t;
+   // Make sure that MsanTSDDtor gets called at the end.
+   CHECK(tsd_key_inited);
++#if !SANITIZER_NETBSD
+   pthread_setspecific(tsd_key, (void *)t);
++#endif
+ }
+ 
+ void MsanTSDDtor(void *tsd) {
++#if !SANITIZER_NETBSD
+   MsanThread *t = (MsanThread*)tsd;
+   if (t->destructor_iterations_ > 1) {
+     t->destructor_iterations_--;
+     CHECK_EQ(0, pthread_setspecific(tsd_key, tsd));
+     return;
+   }
++#endif
+   msan_current_thread = nullptr;
+   // Make sure that signal handler can not see a stale current thread pointer.
+   atomic_signal_fence(memory_order_seq_cst);


Home | Main Index | Thread Index | Old Index