[compiler-rt] r194805 - [Sanitizer] Make slow unwinder on Linux more robust
Alexey Samsonov
samsonov at google.com
Fri Nov 15 02:57:57 PST 2013
Author: samsonov
Date: Fri Nov 15 04:57:56 2013
New Revision: 194805
URL: http://llvm.org/viewvc/llvm-project?rev=194805&view=rev
Log:
[Sanitizer] Make slow unwinder on Linux more robust
Modified:
compiler-rt/trunk/lib/asan/lit_tests/TestCases/double-free.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
Modified: compiler-rt/trunk/lib/asan/lit_tests/TestCases/double-free.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/TestCases/double-free.cc?rev=194805&r1=194804&r2=194805&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/TestCases/double-free.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/TestCases/double-free.cc Fri Nov 15 04:57:56 2013
@@ -14,10 +14,12 @@ int main(int argc, char **argv) {
free(x);
free(x + argc - 1); // BOOM
// CHECK: AddressSanitizer: attempting double-free{{.*}}in thread T0
- // CHECK: double-free.cc:[[@LINE-2]]
+ // CHECK: #0 0x{{.*}} in {{.*}}free
+ // CHECK: #1 0x{{.*}} in main {{.*}}double-free.cc:[[@LINE-3]]
// CHECK: freed by thread T0 here:
- // MALLOC-CTX: double-free.cc:[[@LINE-5]]
+ // MALLOC-CTX: #0 0x{{.*}} in {{.*}}free
+ // MALLOC-CTX: #1 0x{{.*}} in main {{.*}}double-free.cc:[[@LINE-7]]
// CHECK: allocated by thread T0 here:
- // MALLOC-CTX: double-free.cc:[[@LINE-10]]
+ // MALLOC-CTX: double-free.cc:[[@LINE-12]]
return res;
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc?rev=194805&r1=194804&r2=194805&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc Fri Nov 15 04:57:56 2013
@@ -161,7 +161,7 @@ void StackTrace::SlowUnwindStack(uptr pc
UnwindTraceArg arg = {this, Min(max_depth + 1, kStackTraceMax)};
_Unwind_Backtrace(Unwind_Trace, &arg);
// We need to pop a few frames so that pc is on top.
- uptr to_pop = LocatePcInTrace(pc, 6);
+ uptr to_pop = LocatePcInTrace(pc);
// trace[0] belongs to the current function so we always pop it.
if (to_pop == 0)
to_pop = 1;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc?rev=194805&r1=194804&r2=194805&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc Fri Nov 15 04:57:56 2013
@@ -158,12 +158,11 @@ static bool MatchPc(uptr cur_pc, uptr tr
return cur_pc - trace_pc <= threshold || trace_pc - cur_pc <= threshold;
}
-uptr
-StackTrace::LocatePcInTrace(uptr pc, uptr max_pc_depth) {
+uptr StackTrace::LocatePcInTrace(uptr pc) {
// Use threshold to find PC in stack trace, as PC we want to unwind from may
// slightly differ from return address in the actual unwinded stack trace.
- const int kPcThreshold = 64;
- for (uptr i = 0; i < max_pc_depth && i < size; ++i) {
+ const int kPcThreshold = 96;
+ for (uptr i = 0; i < size; ++i) {
if (MatchPc(pc, trace[i], kPcThreshold))
return i;
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h?rev=194805&r1=194804&r2=194805&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h Fri Nov 15 04:57:56 2013
@@ -69,7 +69,7 @@ struct StackTrace {
uptr max_depth);
void SlowUnwindStack(uptr pc, uptr max_depth);
void PopStackFrames(uptr count);
- uptr LocatePcInTrace(uptr pc, uptr max_pc_depth = -1);
+ uptr LocatePcInTrace(uptr pc);
};
} // namespace __sanitizer
More information about the llvm-commits
mailing list