pkgsrc-WIP-changes archive

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

compiler-rt-netbsd: Fix pthread set/get specific usage



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Thu May 3 05:03:50 2018 +0200
Changeset:	9ca9e623d3a4c0d8e16d6203c6b3f0a01e5d9e63

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

Log Message:
compiler-rt-netbsd: Fix pthread set/get specific usage

Cherry-pick a patch from upstream review:
  Asan, fix FreeBSD support
  https://reviews.llvm.org/D45652

Currently ASan sets main thread property with setget specific pthread API.
It's premature to call it before pthread initialization routines.
A patch pending upstream uses a Thread-Local-Storage replacement.

********************
Testing Time: 694.80s
********************
Failing Tests (21):
    LLVMFuzzer :: cxxstring.test
    LLVMFuzzer :: equivalence-signals.test
    LLVMFuzzer :: equivalence.test
    LLVMFuzzer :: fuzzer-leak.test
    LLVMFuzzer :: fuzzer-oom.test
    LLVMFuzzer :: fuzzer-timeout.test
    LLVMFuzzer :: memcmp.test
    LLVMFuzzer :: memcmp64.test
    LLVMFuzzer :: merge-posix.test
    LLVMFuzzer :: recommended-dictionary.test
    LLVMFuzzer :: strcmp.test
    LLVMFuzzer :: strncmp.test
    LLVMFuzzer :: strstr.test
    LLVMFuzzer :: trace-malloc-threaded.test
    LLVMFuzzer :: trace-malloc-unbalanced.test
    LLVMFuzzer :: value-profile-cmp.test
    LLVMFuzzer :: value-profile-load.test
    LLVMFuzzer :: value-profile-mem.test
    LLVMFuzzer :: value-profile-set.test
    LLVMFuzzer :: value-profile-strcmp.test
    LLVMFuzzer :: value-profile-strncmp.test

  Expected Passes    : 87
  Unsupported Tests  : 6
  Unexpected Failures: 21

Warning: oom-killer test can panic the kernel (kill it quickly!)

Few tests can hang:
 - value-profile& (use: $ pkill -9 value-profile)
 - fuzzer-timeout.test

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=9ca9e623d3a4c0d8e16d6203c6b3f0a01e5d9e63

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_asan_asan__posix.cc          | 50 ++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index 1ae9042330..977a8f3ae8 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -1,6 +1,7 @@
 $NetBSD: distinfo,v 1.35 2015/09/11 01:21:57 tnn Exp $
 
 SHA1 (patch-cmake_config-ix.cmake) = 720ede87150ae1ac59d8415c77644d917da9cd16
+SHA1 (patch-lib_asan_asan__posix.cc) = 0f596061c078eaab0b5b4b183550aa7820677f46
 SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = 766b817c2ede73ca90d6e25a4b8330ed3d38b84b
 SHA1 (patch-lib_msan_msan__interceptors.cc) = 0aa08e580841d2ff99e01de03ca903e13d5ea497
 SHA1 (patch-lib_msan_msan__linux.cc) = 6fd2ada4a84d1e1cc47ec8f4e1f0608861c73c1a
diff --git a/compiler-rt-netbsd/patches/patch-lib_asan_asan__posix.cc b/compiler-rt-netbsd/patches/patch-lib_asan_asan__posix.cc
new file mode 100644
index 0000000000..91acb1083e
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_asan_asan__posix.cc
@@ -0,0 +1,50 @@
+$NetBSD$
+
+--- lib/asan/asan_posix.cc.orig	2018-02-01 23:46:05.000000000 +0000
++++ lib/asan/asan_posix.cc
+@@ -40,31 +40,35 @@ void AsanOnDeadlySignal(int signo, void 
+ 
+ // ---------------------- TSD ---------------- {{{1
+ 
+-static pthread_key_t tsd_key;
++struct TsdKey {
++  void *data;
++  void (*dst)(void *value);
++  TsdKey() : data(nullptr), dst(nullptr) {}
++  ~TsdKey() {
++    if (dst)
++      dst(data);
++  }
++};
++
++static thread_local TsdKey Tk;
+ static bool tsd_key_inited = false;
+ void AsanTSDInit(void (*destructor)(void *tsd)) {
+   CHECK(!tsd_key_inited);
+   tsd_key_inited = true;
+-  CHECK_EQ(0, pthread_key_create(&tsd_key, destructor));
++  Tk.dst = destructor;
+ }
+ 
+ void *AsanTSDGet() {
+   CHECK(tsd_key_inited);
+-  return pthread_getspecific(tsd_key);
++  return Tk.data;
+ }
+ 
+ void AsanTSDSet(void *tsd) {
+   CHECK(tsd_key_inited);
+-  pthread_setspecific(tsd_key, tsd);
++  Tk.data = tsd;
+ }
+ 
+ void PlatformTSDDtor(void *tsd) {
+-  AsanThreadContext *context = (AsanThreadContext*)tsd;
+-  if (context->destructor_iterations > 1) {
+-    context->destructor_iterations--;
+-    CHECK_EQ(0, pthread_setspecific(tsd_key, tsd));
+-    return;
+-  }
+   AsanThread::TSDDtor(tsd);
+ }
+ }  // namespace __asan


Home | Main Index | Thread Index | Old Index