summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChuang-Yu Cheng <cycheng@multicorewareinc.com>2016-04-20 10:28:41 +0000
committerChuang-Yu Cheng <cycheng@multicorewareinc.com>2016-04-20 10:28:41 +0000
commit3d3960422d85cb2bbce30e7fc0e9304a9c5a715e (patch)
treeba7f6de8cfef889353300738c9dc563cd1f8f80f /lib
parent2d7f4d38d2ceb4f5b80865af34106e40233e1061 (diff)
Always inlining PrintCurrentStackSlow of tsan library to fix tail-call issue
The real problem is that sanitizer_print_stack_trace obtains current PC and expects the PC to be in the stack trace after function calls. We don't prevent tail calls in sanitizer runtimes, so this assumption does not necessary hold. We add "always inline" attribute on PrintCurrentStackSlow to address this issue, however this solution is not reliable enough, but unfortunately, we don't see any simple, reliable solution. Reviewers: samsonov hfinkel kbarton tjablin dvyukov kcc http://reviews.llvm.org/D19148 Thanks Hal, dvyukov, and kcc for invaluable discussion, I have even borrowed part of dvyukov's summary as my commit message! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266869 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/tsan/rtl/tsan_rtl_report.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/tsan/rtl/tsan_rtl_report.cc b/lib/tsan/rtl/tsan_rtl_report.cc
index cd82af4f6..ac89830be 100644
--- a/lib/tsan/rtl/tsan_rtl_report.cc
+++ b/lib/tsan/rtl/tsan_rtl_report.cc
@@ -680,6 +680,14 @@ void PrintCurrentStack(ThreadState *thr, uptr pc) {
PrintStack(SymbolizeStack(trace));
}
+// Always inlining PrintCurrentStackSlow, because LocatePcInTrace assumes
+// __sanitizer_print_stack_trace exists in the actual unwinded stack, but
+// tail-call to PrintCurrentStackSlow breaks this assumption because
+// __sanitizer_print_stack_trace disappears after tail-call.
+// However, this solution is not reliable enough, please see dvyukov's comment
+// http://reviews.llvm.org/D19148#406208
+// Also see PR27280 comment 2 and 3 for breaking examples and analysis.
+ALWAYS_INLINE
void PrintCurrentStackSlow(uptr pc) {
#ifndef SANITIZER_GO
BufferedStackTrace *ptrace =