From 6d5bd599c29fc6e968dabfbbcab105f6ff7a3108 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 4 Oct 2012 13:54:49 +0000 Subject: [PATCH] tsan for Go: support mallocs before __tsan_init() (required to support cgo code) llvm-svn: 165229 --- compiler-rt/lib/tsan/go/tsan_go.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/tsan/go/tsan_go.cc b/compiler-rt/lib/tsan/go/tsan_go.cc index 77da9fe..eca6cae 100644 --- a/compiler-rt/lib/tsan/go/tsan_go.cc +++ b/compiler-rt/lib/tsan/go/tsan_go.cc @@ -105,7 +105,7 @@ void __tsan_fini() { thr->in_rtl++; int res = Finalize(thr); thr->in_rtl--; - exit(res); + exit(res); } void __tsan_read(int goid, void *addr, void *pc) { @@ -130,6 +130,8 @@ void __tsan_func_exit(int goid) { void __tsan_malloc(int goid, void *p, uptr sz, void *pc) { ThreadState *thr = goroutines[goid]; + if (thr == 0) // probably before __tsan_init() + return; thr->in_rtl++; MemoryResetRange(thr, (uptr)pc, (uptr)p, sz); MemoryAccessRange(thr, (uptr)pc, (uptr)p, sz, true); -- 2.7.4