pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
compiler-rt-netbsd: Sync with local enhancements
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Thu Nov 2 19:11:20 2017 +0100
Changeset: a6f0146a7e841ace164ab19fe90e89d270e227e4
Modified Files:
compiler-rt-netbsd/distinfo
compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
Removed Files:
compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
Log Message:
compiler-rt-netbsd: Sync with local enhancements
1. Drop the patch disabling SANITIZER_INTERCEPT_PHTREAD_MUTEX
2. Disable hack in at_exit_wrapper() that disabled functionality of this
function. There is required a fix for handling __cxa_atexit() with dso=NULL.
Example patch:
http://netbsd.org/~kamil/patch-00038-__cxa_atexit.txt
3. Rewrite thread anhilation. Add purely NetBSD specific code, disable
the usage of pthread_key_create(3) that does not work on NetBSD, because
we still call at mutex loc/unlock after firing destructors. Intercept
_lwp_exit(2) for this purpose.
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=a6f0146a7e841ace164ab19fe90e89d270e227e4
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
compiler-rt-netbsd/distinfo | 3 +-
...zer__common_sanitizer__common__interceptors.inc | 13 --
.../patch-lib_tsan_rtl_tsan__interceptors.cc | 140 ++++++++-------------
3 files changed, 54 insertions(+), 102 deletions(-)
diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index 23999c2261..d5f67bd127 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -3,7 +3,6 @@ $NetBSD: distinfo,v 1.35 2015/09/11 01:21:57 tnn Exp $
SHA1 (patch-cmake_config-ix.cmake) = a1814db3e044ce3954655fea1e157a96bfa8df2f
SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = 38ca750154dfc9843a56748078235824b772a147
SHA1 (patch-lib_msan_msan.h) = ce3f544490aebc1db73be9e3388f0a9d31d5b369
-SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = ec1d31397b5036aedecd6e110a1f898558f0273e
-SHA1 (patch-lib_tsan_rtl_tsan__interceptors.cc) = efb9469d5c49a556c605545bfbbbd53ff7a2169d
+SHA1 (patch-lib_tsan_rtl_tsan__interceptors.cc) = 1247b3395ff2d5e9158895d141289cc315587797
SHA1 (patch-lib_tsan_rtl_tsan__rtl.cc) = bc3d6aa81515ac4a4fc5b504e93b3ac8de355371
SHA1 (patch-lib_tsan_rtl_tsan__rtl__amd64.S) = 6df0f2af44ebfec76d3b237c984eff63ee93b30f
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
deleted file mode 100644
index fd14017a36..0000000000
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
+++ /dev/null
@@ -1,13 +0,0 @@
-$NetBSD$
-
---- lib/sanitizer_common/sanitizer_common_interceptors.inc.orig 2017-10-25 19:03:28.000000000 +0000
-+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
-@@ -3795,7 +3795,7 @@ INTERCEPTOR(void, _exit, int status) {
- #define INIT__EXIT
- #endif
-
--#if SANITIZER_INTERCEPT_PHTREAD_MUTEX
-+#if SANITIZER_INTERCEPT_PHTREAD_MUTEX && 0
- INTERCEPTOR(int, pthread_mutex_lock, void *m) {
- void *ctx;
- COMMON_INTERCEPTOR_ENTER(ctx, pthread_mutex_lock, m);
diff --git a/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
index 6870f6d066..fea3c2b207 100644
--- a/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
@@ -2,100 +2,66 @@ $NetBSD$
--- lib/tsan/rtl/tsan_interceptors.cc.orig 2017-10-25 19:03:27.000000000 +0000
+++ lib/tsan/rtl/tsan_interceptors.cc
-@@ -395,9 +395,9 @@ static void at_exit_wrapper(void *arg) {
- ThreadState *thr = cur_thread();
- uptr pc = 0;
- Acquire(thr, pc, (uptr)arg);
-- AtExitCtx *ctx = (AtExitCtx*)arg;
-- ((void(*)(void *arg))ctx->f)(ctx->arg);
-- InternalFree(ctx);
-+// AtExitCtx *ctx = (AtExitCtx*)arg;
-+// ((void(*)(void *arg))ctx->f)(ctx->arg);
-+// InternalFree(ctx);
+@@ -265,7 +265,7 @@ static ThreadSignalContext *SigCtx(Threa
+ return ctx;
}
- static int setup_at_exit_wrapper(ThreadState *thr, uptr pc, void(*f)(),
-@@ -920,6 +920,39 @@ extern "C" void *__tsan_thread_start_fun
- return res;
- }
-
-+static void FlushStreams() {
-+ // Flushing all the streams here may freeze the process if a child thread is
-+ // performing file stream operations at the same time.
-+
-+ REAL(fflush)(stdout);
-+ REAL(fflush)(stderr);
-+}
-+
-+static void finalize(void *arg) {
-+ using namespace __tsan;
-+ ThreadState *thr = cur_thread();
-+ int status = Finalize(thr);
-+ // Make sure the output is not lost.
-+ FlushStreams();
-+ if (status)
-+ Die();
-+}
-+
-+__attribute__((constructor))
-+//__attribute__((section(".init_array")))
-+static void
-+yikes1(void) {
-+ if (REAL(__cxa_atexit)(&finalize, 0, 0)) {
-+ Printf("ThreadSanitizer: failed to setup atexit callback\n");
-+ Die();
-+ }
-+
-+ if (pthread_key_create(&g_thread_finalize_key, &thread_finalize)) {
-+ Printf("ThreadSanitizer: failed to create thread key\n");
-+ Die();
-+ }
-+}
-+
- TSAN_INTERCEPTOR(int, pthread_create,
- void *th, void *attr, void *(*callback)(void*), void * param) {
- SCOPED_INTERCEPTOR_RAW(pthread_create, th, attr, callback, param);
-@@ -1675,12 +1708,12 @@ TSAN_INTERCEPTOR(void*, tmpfile64, int f
- #define TSAN_MAYBE_INTERCEPT_TMPFILE64
+-#if !SANITIZER_MAC
++#if !SANITIZER_MAC && !SANITIZER_NETBSD
+ static unsigned g_thread_finalize_key;
#endif
--static void FlushStreams() {
-- // Flushing all the streams here may freeze the process if a child thread is
-- // performing file stream operations at the same time.
-- REAL(fflush)(stdout);
-- REAL(fflush)(stderr);
--}
-+//static void FlushStreams() {
-+// // Flushing all the streams here may freeze the process if a child thread is
-+// // performing file stream operations at the same time.
-+// REAL(fflush)(stdout);
-+// REAL(fflush)(stderr);
-+//}
+@@ -866,7 +866,7 @@ void DestroyThreadState() {
+ }
+ } // namespace __tsan
- TSAN_INTERCEPTOR(void, abort, int fake) {
- SCOPED_TSAN_INTERCEPTOR(abort, fake);
-@@ -2619,16 +2652,16 @@ void InitializeInterceptors() {
- REAL(atexit) = (int(*)(void(*)()))unreachable;
+-#if !SANITIZER_MAC
++#if !SANITIZER_MAC && !SANITIZER_NETBSD
+ static void thread_finalize(void *v) {
+ uptr iter = (uptr)v;
+ if (iter > 1) {
+@@ -896,7 +896,7 @@ extern "C" void *__tsan_thread_start_fun
+ ThreadState *thr = cur_thread();
+ // Thread-local state is not initialized yet.
+ ScopedIgnoreInterceptors ignore;
+-#if !SANITIZER_MAC
++#if !SANITIZER_MAC && !SANITIZER_NETBSD
+ ThreadIgnoreBegin(thr, 0);
+ if (pthread_setspecific(g_thread_finalize_key,
+ (void *)GetPthreadDestructorIterations())) {
+@@ -2445,6 +2445,17 @@ TSAN_INTERCEPTOR(void *, __tls_get_addr,
+ }
#endif
-- if (REAL(__cxa_atexit)(&finalize, 0, 0)) {
-- Printf("ThreadSanitizer: failed to setup atexit callback\n");
-- Die();
-- }
-+// if (REAL(__cxa_atexit)(&finalize, 0, 0)) {
-+// Printf("ThreadSanitizer: failed to setup atexit callback\n");
-+// Die();
-+// }
++#if SANITIZER_NETBSD
++TSAN_INTERCEPTOR(void, _lwp_exit) {
++ SCOPED_TSAN_INTERCEPTOR(_lwp_exit);
++ DestroyThreadState();
++ REAL(_lwp_exit)();
++}
++#define TSAN_MAYBE_INTERCEPT__LWP_EXIT TSAN_INTERCEPT(_lwp_exit)
++#else
++#define TSAN_MAYBE_INTERCEPT__LWP_EXIT
++#endif
++
+ namespace __tsan {
- #if !SANITIZER_MAC
-- if (pthread_key_create(&g_thread_finalize_key, &thread_finalize)) {
-- Printf("ThreadSanitizer: failed to create thread key\n");
-- Die();
-- }
-+// if (pthread_key_create(&g_thread_finalize_key, &thread_finalize)) {
-+// Printf("ThreadSanitizer: failed to create thread key\n");
-+// Die();
-+// }
+ static void finalize(void *arg) {
+@@ -2613,6 +2624,8 @@ void InitializeInterceptors() {
+ TSAN_INTERCEPT(__tls_get_addr);
#endif
- FdInit();
++ TSAN_MAYBE_INTERCEPT__LWP_EXIT;
++
+ #if !SANITIZER_MAC && !SANITIZER_ANDROID
+ // Need to setup it, because interceptors check that the function is resolved.
+ // But atexit is emitted directly into the module, so can't be resolved.
+@@ -2624,7 +2637,7 @@ void InitializeInterceptors() {
+ Die();
+ }
+
+-#if !SANITIZER_MAC
++#if !SANITIZER_MAC && !SANITIZER_NETBSD
+ if (pthread_key_create(&g_thread_finalize_key, &thread_finalize)) {
+ Printf("ThreadSanitizer: failed to create thread key\n");
+ Die();
Home |
Main Index |
Thread Index |
Old Index