From 0b168ffdc3fff3f88edaaa7de7444c119cbbdfc2 Mon Sep 17 00:00:00 2001 From: Alexander Richardson Date: Tue, 6 Aug 2019 22:30:48 +0000 Subject: [PATCH] [TSAN] Fix tsan on FreeBSD after D54889 Summary: It appears that since https://reviews.llvm.org/D54889, BackgroundThread() crashes immediately because cur_thread()-> will return a null pointer which is then dereferenced. I'm not sure why I only see this issue on FreeBSD and not Linux since it should also be unintialized on other platforms. Reviewers: yuri, dvyukov, dim, emaste Subscribers: kubamracek, krytarowski, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D65705 llvm-svn: 368103 --- compiler-rt/lib/tsan/rtl/tsan_rtl.cpp | 1 + compiler-rt/test/tsan/ignored-interceptors-mmap.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp index 312d00c6f92e..1ac3907094b9 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp @@ -149,6 +149,7 @@ static void BackgroundThread(void *arg) { // We don't use ScopedIgnoreInterceptors, because we want ignores to be // enabled even when the thread function exits (e.g. during pthread thread // shutdown code). + cur_thread_init(); cur_thread()->ignore_interceptors++; const u64 kMs2Ns = 1000 * 1000; diff --git a/compiler-rt/test/tsan/ignored-interceptors-mmap.cpp b/compiler-rt/test/tsan/ignored-interceptors-mmap.cpp index bb43250a659d..bcfafa409914 100644 --- a/compiler-rt/test/tsan/ignored-interceptors-mmap.cpp +++ b/compiler-rt/test/tsan/ignored-interceptors-mmap.cpp @@ -1,7 +1,7 @@ // RUN: %clangxx_tsan -O0 %s -o %t // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-RACE // RUN: %run %t ignore 2>&1 | FileCheck %s --check-prefix=CHECK-IGNORE -// XFAIL: freebsd,netbsd +// XFAIL: netbsd #include #include