summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2013-09-19 04:48:59 +0000
committerDmitry Vyukov <dvyukov@google.com>2013-09-19 04:48:59 +0000
commitf54631dcfe460a7b5febe565918ea737867b6a71 (patch)
tree2efde12d1940f3c6f4b3bfed8fc988443ec83d0b /compiler-rt/lib/tsan
parentc2437ffc2368b32bca245d2a7bec5c5649d27261 (diff)
downloadbcm5719-llvm-f54631dcfe460a7b5febe565918ea737867b6a71.tar.gz
bcm5719-llvm-f54631dcfe460a7b5febe565918ea737867b6a71.zip
tsan: prevent the following false positive due to __cxa_atexit
WARNING: ThreadSanitizer: data race (pid=29103) Write of size 8 at 0x7d64003bbf00 by main thread: #0 free tsan_interceptors.cc:477 #1 __run_exit_handlers <null>:0 (libc.so.6+0x000000050cb7) Previous write of size 8 at 0x7d64003bbf00 by thread T78 (mutexes: write M9896): #0 calloc tsan_interceptors.cc:449 #1 ... llvm-svn: 190989
Diffstat (limited to 'compiler-rt/lib/tsan')
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_interceptors.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
index 1997d40bf19..7843cd7535c 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
@@ -313,8 +313,14 @@ TSAN_INTERCEPTOR(int, __cxa_atexit, void (*f)(void *a), void *arg, void *dso) {
if (cur_thread()->in_symbolizer)
return 0;
SCOPED_TSAN_INTERCEPTOR(__cxa_atexit, f, arg, dso);
- if (dso)
- return REAL(__cxa_atexit)(f, arg, dso);
+ if (dso) {
+ // Memory allocation in __cxa_atexit will race with free during exit,
+ // because we do not see synchronization around atexit callback list.
+ ThreadIgnoreBegin(thr);
+ int res = REAL(__cxa_atexit)(f, arg, dso);
+ ThreadIgnoreEnd(thr);
+ return res;
+ }
return atexit_ctx->atexit(thr, pc, false, (void(*)())f, arg);
}
OpenPOWER on IntegriCloud