[compiler-rt] r372205 - tsan: allow the Go runtime to return multiple stack frames for a single PC
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 02:18:04 PDT 2019
Author: dvyukov
Date: Wed Sep 18 02:18:04 2019
New Revision: 372205
URL: http://llvm.org/viewvc/llvm-project?rev=372205&view=rev
Log:
tsan: allow the Go runtime to return multiple stack frames for a single PC
This fix allows tsan to report stack traces correctly even in the
presence of mid-stack inlining by the Go compiler.
See https://go-review.googlesource.com/c/go/+/195781 for the Go runtime side of this change.
Author: randall77 (Keith Randall)
Reviewed: https://reviews.llvm.org/D67671
Modified:
compiler-rt/trunk/lib/tsan/go/tsan_go.cpp
Modified: compiler-rt/trunk/lib/tsan/go/tsan_go.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/tsan_go.cpp?rev=372205&r1=372204&r2=372205&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/tsan_go.cpp (original)
+++ compiler-rt/trunk/lib/tsan/go/tsan_go.cpp Wed Sep 18 02:18:04 2019
@@ -54,20 +54,31 @@ struct SymbolizeCodeContext {
};
SymbolizedStack *SymbolizeCode(uptr addr) {
- SymbolizedStack *s = SymbolizedStack::New(addr);
- SymbolizeCodeContext cbctx;
- internal_memset(&cbctx, 0, sizeof(cbctx));
- cbctx.pc = addr;
- go_runtime_cb(CallbackSymbolizeCode, &cbctx);
- if (cbctx.res) {
+ SymbolizedStack *first = SymbolizedStack::New(addr);
+ SymbolizedStack *s = first;
+ for (;;) {
+ SymbolizeCodeContext cbctx;
+ internal_memset(&cbctx, 0, sizeof(cbctx));
+ cbctx.pc = addr;
+ go_runtime_cb(CallbackSymbolizeCode, &cbctx);
+ if (cbctx.res == 0)
+ break;
AddressInfo &info = s->info;
info.module_offset = cbctx.off;
info.function = internal_strdup(cbctx.func ? cbctx.func : "??");
info.file = internal_strdup(cbctx.file ? cbctx.file : "-");
info.line = cbctx.line;
info.column = 0;
+
+ if (cbctx.pc == addr) // outermost (non-inlined) function
+ break;
+ addr = cbctx.pc;
+ // Allocate a stack entry for the parent of the inlined function.
+ SymbolizedStack *s2 = SymbolizedStack::New(addr);
+ s->next = s2;
+ s = s2;
}
- return s;
+ return first;
}
struct SymbolizeDataContext {
More information about the llvm-commits
mailing list