diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2014-03-06 13:17:28 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2014-03-06 13:17:28 +0000 |
commit | 2f3c76a22c6efef0be1243792fd94ea7e8392243 (patch) | |
tree | 3df2c62922c13d4ff0a7aafd516462d59dc3997c /lib/tsan/go | |
parent | b5079421e7a086b207df4d655e006145f5560ead (diff) |
tsan: update interface for Go
this is required to fix:
https://code.google.com/p/go/issues/detail?id=7460
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@203116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/go')
-rw-r--r-- | lib/tsan/go/test.c | 5 | ||||
-rw-r--r-- | lib/tsan/go/tsan_go.cc | 8 |
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/tsan/go/test.c b/lib/tsan/go/test.c index 2e31773b8..94433f1b8 100644 --- a/lib/tsan/go/test.c +++ b/lib/tsan/go/test.c @@ -22,7 +22,7 @@ void __tsan_read(void *thr, void *addr, void *pc); void __tsan_write(void *thr, void *addr, void *pc); void __tsan_func_enter(void *thr, void *pc); void __tsan_func_exit(void *thr); -void __tsan_malloc(void *thr, void *p, unsigned long sz, void *pc); +void __tsan_malloc(void *p, unsigned long sz); void __tsan_acquire(void *thr, void *addr); void __tsan_release(void *thr, void *addr); void __tsan_release_merge(void *thr, void *addr); @@ -37,10 +37,11 @@ void barfoo() {} int main(void) { void *thr0 = 0; char *buf = (char*)((unsigned long)buf0 + (64<<10) - 1 & ~((64<<10) - 1)); + __tsan_malloc(buf, 10); __tsan_init(&thr0, symbolize_cb); __tsan_map_shadow(buf, 4096); __tsan_func_enter(thr0, (char*)&main + 1); - __tsan_malloc(thr0, buf, 10, 0); + __tsan_malloc(buf, 10); __tsan_release(thr0, buf); __tsan_release_merge(thr0, buf); void *thr1 = 0; diff --git a/lib/tsan/go/tsan_go.cc b/lib/tsan/go/tsan_go.cc index ae4266882..ff4e0ee0f 100644 --- a/lib/tsan/go/tsan_go.cc +++ b/lib/tsan/go/tsan_go.cc @@ -85,6 +85,7 @@ ReportStack *SymbolizeCode(uptr addr) { extern "C" { static ThreadState *main_thr; +static bool inited; static ThreadState *AllocGoroutine() { ThreadState *thr = (ThreadState*)internal_alloc(MBlockThreadContex, @@ -98,6 +99,7 @@ void __tsan_init(ThreadState **thrp, void (*cb)(SymbolizeContext *cb)) { ThreadState *thr = AllocGoroutine(); main_thr = *thrp = thr; Initialize(thr); + inited = true; } void __tsan_fini() { @@ -151,10 +153,10 @@ void __tsan_func_exit(ThreadState *thr) { FuncExit(thr); } -void __tsan_malloc(ThreadState *thr, void *p, uptr sz, void *pc) { - if (thr == 0) // probably before __tsan_init() +void __tsan_malloc(void *p, uptr sz) { + if (!inited) return; - MemoryResetRange(thr, (uptr)pc, (uptr)p, sz); + MemoryResetRange(0, 0, (uptr)p, sz); } void __tsan_go_start(ThreadState *parent, ThreadState **pthr, void *pc) { |