[TSAN] Fix tsan on FreeBSD after D54889
authorAlexander Richardson <arichardson.kde@gmail.com>
Tue, 6 Aug 2019 22:30:48 +0000 (22:30 +0000)
committerAlexander Richardson <arichardson.kde@gmail.com>
Tue, 6 Aug 2019 22:30:48 +0000 (22:30 +0000)
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
compiler-rt/test/tsan/ignored-interceptors-mmap.cpp

index 312d00c6f92ec01623a6dee6c5ceebfb66838af4..1ac3907094b9ec2b954dffebd31e53b04545176a 100644 (file)
@@ -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;
 
index bb43250a659d53611463c14ca69b6a6905c6ddde..bcfafa40991449819ed39d586ee965f4e1945747 100644 (file)
@@ -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 <sys/mman.h>
 #include <string.h>