tsan: do not call malloc/free in memory access handling routine.
This improves signal-/fork-safety of instrumented programs.
llvm-svn: 158988
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
index 4adbe35..a66f672 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
@@ -219,12 +219,14 @@
}
static void TraceSwitch(ThreadState *thr) {
+ thr->nomalloc++;
ScopedInRtl in_rtl;
Lock l(&thr->trace.mtx);
unsigned trace = (thr->fast_state.epoch() / kTracePartSize) % kTraceParts;
TraceHeader *hdr = &thr->trace.headers[trace];
hdr->epoch0 = thr->fast_state.epoch();
hdr->stack0.ObtainCurrent(thr, 0);
+ thr->nomalloc--;
}
extern "C" void __tsan_trace_switch() {