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 | 6a58b0078a94195f963fede873068d7a0982c509 (patch) | |
tree | 243e149d9bce01ed18cc3bea75c05dd9fea934fc | |
parent | 5b2d43008240767872d0fe4913b3e5b784954e43 (diff) | |
download | compiler-rt-6a58b0078a94195f963fede873068d7a0982c509.tar.gz |
[Sanitizer] Make slow unwinder on Linux more robust
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194805 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/asan/lit_tests/TestCases/double-free.cc | 8 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_linux_libcdep.cc | 2 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_stacktrace.cc | 7 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_stacktrace.h | 2 |
4 files changed, 10 insertions, 9 deletions
diff --git a/lib/asan/lit_tests/TestCases/double-free.cc b/lib/asan/lit_tests/TestCases/double-free.cc index e66817e91..6bfd4fa2c 100644 --- a/lib/asan/lit_tests/TestCases/double-free.cc +++ b/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/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc index f6de9f1f8..2940686f1 100644 --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ b/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/lib/sanitizer_common/sanitizer_stacktrace.cc b/lib/sanitizer_common/sanitizer_stacktrace.cc index 62cb12d8d..70ce26bde 100644 --- a/lib/sanitizer_common/sanitizer_stacktrace.cc +++ b/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/lib/sanitizer_common/sanitizer_stacktrace.h b/lib/sanitizer_common/sanitizer_stacktrace.h index 73474e65b..5042f2301 100644 --- a/lib/sanitizer_common/sanitizer_stacktrace.h +++ b/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 |