forked from OSchip/llvm-project
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
This commit is contained in:
parent
c2437ffc23
commit
f54631dcfe
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue