diff options
| author | Alexey Samsonov <samsonov@google.com> | 2013-11-15 10:57:56 +0000 |
|---|---|---|
| committer | Alexey Samsonov <samsonov@google.com> | 2013-11-15 10:57:56 +0000 |
| commit | a6e8322fb1e57df5d2d1bd4833e66853446d4879 (patch) | |
| tree | 478550eace011286020ef8b7b4aa495a616f12df /compiler-rt | |
| parent | a25cf71894052301d1dbf0ba6d250af1c5553563 (diff) | |
| download | bcm5719-llvm-a6e8322fb1e57df5d2d1bd4833e66853446d4879.tar.gz bcm5719-llvm-a6e8322fb1e57df5d2d1bd4833e66853446d4879.zip | |
[Sanitizer] Make slow unwinder on Linux more robust
llvm-svn: 194805
Diffstat (limited to 'compiler-rt')
4 files changed, 10 insertions, 9 deletions
diff --git a/compiler-rt/lib/asan/lit_tests/TestCases/double-free.cc b/compiler-rt/lib/asan/lit_tests/TestCases/double-free.cc index e66817e9108..6bfd4fa2c7e 100644 --- a/compiler-rt/lib/asan/lit_tests/TestCases/double-free.cc +++ b/compiler-rt/lib/asan/lit_tests/TestCases/double-free.cc @@ -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; } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc index f6de9f1f815..2940686f127 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc @@ -161,7 +161,7 @@ void StackTrace::SlowUnwindStack(uptr pc, uptr max_depth) { 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; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc index 62cb12d8da6..70ce26bde0d 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc @@ -158,12 +158,11 @@ static bool MatchPc(uptr cur_pc, uptr trace_pc, uptr threshold) { 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; } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h index 73474e65b6a..5042f230188 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h @@ -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 |

