From 6c33998ce1a03bc770943015d8cb5d477ee66bd8 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 30 Apr 2018 07:28:45 +0000 Subject: [PATCH] tsan: disable trace switching after multithreaded fork The problem is reported in: https://github.com/google/sanitizers/issues/945 We already disable as much as possible after multithreaded fork, trace switching is last place that can hang due to basic operations (memory accesses, function calls). Disable it too. llvm-svn: 331163 --- compiler-rt/lib/tsan/rtl/tsan_rtl.cc | 4 ++++ compiler-rt/lib/tsan/rtl/tsan_rtl.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc index 17b8209..404fb80 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc @@ -547,6 +547,10 @@ u32 CurrentStackId(ThreadState *thr, uptr pc) { } void TraceSwitch(ThreadState *thr) { +#if !SANITIZER_GO + if (ctx->after_multithreaded_fork) + return; +#endif thr->nomalloc++; Trace *thr_trace = ThreadTrace(thr->tid); Lock l(&thr_trace->mtx); diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h index 7d44cca..5e2a745 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h @@ -520,7 +520,9 @@ struct Context { Context(); bool initialized; +#if !SANITIZER_GO bool after_multithreaded_fork; +#endif MetaMap metamap; -- 2.7.4