[PATCH] D32517: [ubsan] Request the fast unwinder when print_stacktrace=1
Vedant Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 25 18:06:57 PDT 2017
vsk created this revision.
This makes it possible to get stacktrace info when print_stacktrace=1 on
Darwin (where the slow unwinder is not currently supported [1]). This
should not regress any other platforms (Windows will fall back to the
slow unwinder).
[1] The thread about r300295 has a relatively recent discusion about
this. We should be able to enable the existing slow unwind functionality
for Darwin, but this needs more testing.
https://reviews.llvm.org/D32517
Files:
lib/ubsan/ubsan_diag.cc
test/ubsan/TestCases/Misc/missing_return.cpp
test/ubsan/TestCases/TypeCheck/misaligned.cpp
Index: test/ubsan/TestCases/TypeCheck/misaligned.cpp
===================================================================
--- test/ubsan/TestCases/TypeCheck/misaligned.cpp
+++ test/ubsan/TestCases/TypeCheck/misaligned.cpp
@@ -47,11 +47,8 @@
// CHECK-LOAD-NEXT: {{^ 00 00 00 01 02 03 04 05}}
// CHECK-LOAD-NEXT: {{^ \^}}
return *p && 0;
- // Slow stack unwinding is disabled on Darwin for now, see
- // https://code.google.com/p/address-sanitizer/issues/detail?id=137
// CHECK-Linux-STACK-LOAD: #0 {{.*}}main{{.*}}misaligned.cpp
- // Check for the already checked line to avoid lit error reports.
- // CHECK-Darwin-STACK-LOAD: {{ }}
+ // CHECK-Darwin-STACK-LOAD: #0 {{.*}}main{{.*}}misaligned.cpp
case 's':
// CHECK-STORE: misaligned.cpp:[[@LINE+4]]{{(:5)?}}: runtime error: store to misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
Index: test/ubsan/TestCases/Misc/missing_return.cpp
===================================================================
--- test/ubsan/TestCases/Misc/missing_return.cpp
+++ test/ubsan/TestCases/Misc/missing_return.cpp
@@ -4,10 +4,9 @@
// CHECK: missing_return.cpp:[[@LINE+1]]:5: runtime error: execution reached the end of a value-returning function without returning a value
int f() {
-// Slow stack unwinding is not available on Darwin for now, see
-// https://code.google.com/p/address-sanitizer/issues/detail?id=137
-// CHECK-Linux-STACKTRACE: #0 {{.*}}f(){{.*}}missing_return.cpp:[[@LINE-3]]
-// CHECK-FreeBSD-STACKTRACE: #0 {{.*}}f(void){{.*}}missing_return.cpp:[[@LINE-4]]
+// CHECK-Linux-STACKTRACE: #0 {{.*}}f(){{.*}}missing_return.cpp:[[@LINE-1]]
+// CHECK-FreeBSD-STACKTRACE: #0 {{.*}}f(void){{.*}}missing_return.cpp:[[@LINE-2]]
+// CHECK-Darwin-STACKTRACE: #0 {{.*}}f(){{.*}}missing_return.cpp:[[@LINE-3]]
}
int main(int, char **argv) {
Index: lib/ubsan/ubsan_diag.cc
===================================================================
--- lib/ubsan/ubsan_diag.cc
+++ lib/ubsan/ubsan_diag.cc
@@ -31,15 +31,12 @@
// will definitely be called when we print the first diagnostics message.
if (!flags()->print_stacktrace)
return;
- // We can only use slow unwind, as we don't have any information about stack
- // top/bottom.
- // FIXME: It's better to respect "fast_unwind_on_fatal" runtime flag and
- // fetch stack top/bottom information if we have it (e.g. if we're running
- // under ASan).
- if (StackTrace::WillUseFastUnwind(false))
- return;
+
+ uptr top, bottom;
+ __sanitizer::GetThreadStackTopAndBottom(false, &top, &bottom);
BufferedStackTrace stack;
- stack.Unwind(kStackTraceMax, pc, bp, 0, 0, 0, false);
+ stack.Unwind(kStackTraceMax, pc, bp, nullptr, top, bottom,
+ /*request_fast_unwind=*/true);
stack.Print();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32517.96662.patch
Type: text/x-patch
Size: 2820 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170426/7e7c260b/attachment.bin>
More information about the llvm-commits
mailing list