From dcad913ab66fde15d00c8d5116b00efef082cc41 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 20 Jul 2016 10:29:08 +0000 Subject: [PATCH] tsan: fix leak of shadow stacks llvm-svn: 276103 --- compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc index ab8f3c38a960..13528ae980e1 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc @@ -125,6 +125,12 @@ void ThreadContext::OnStarted(void *arg) { } void ThreadContext::OnFinished() { +#ifdef SANITIZER_GO + internal_free(thr->shadow_stack); + thr->shadow_stack = nullptr; + thr->shadow_stack_pos = nullptr; + thr->shadow_stack_end = nullptr; +#endif if (!detached) { thr->fast_state.IncrementEpoch(); // Can't increment epoch w/o writing to the trace as well.