Index: lib/sanitizer_common/sanitizer_stacktrace.h =================================================================== --- lib/sanitizer_common/sanitizer_stacktrace.h +++ lib/sanitizer_common/sanitizer_stacktrace.h @@ -19,8 +19,7 @@ static const u32 kStackTraceMax = 256; -#if SANITIZER_LINUX && (defined(__aarch64__) || defined(__powerpc__) || \ - defined(__powerpc64__) || defined(__sparc__) || \ +#if SANITIZER_LINUX && (defined(__aarch64__) || defined(__sparc__) || \ defined(__mips__)) # define SANITIZER_CAN_FAST_UNWIND 0 #elif SANITIZER_WINDOWS Index: lib/sanitizer_common/sanitizer_stacktrace.cc =================================================================== --- lib/sanitizer_common/sanitizer_stacktrace.cc +++ lib/sanitizer_common/sanitizer_stacktrace.cc @@ -17,6 +17,16 @@ namespace __sanitizer { + +#if defined(__powerpc__) || defined(__powerpc64__) + static const int kOffsetToPcInFrame = 2; + static const bool kFastUnwindAddPC = false; +#else + static const int kOffsetToPcInFrame = 1; + static const bool kFastUnwindAddPC = true; +#endif + + uptr StackTrace::GetNextInstructionPc(uptr pc) { #if defined(__mips__) return pc + 8; @@ -70,8 +80,12 @@ void BufferedStackTrace::FastUnwindStack(uptr pc, uptr bp, uptr stack_top, uptr stack_bottom, u32 max_depth) { CHECK_GE(max_depth, 2); - trace_buffer[0] = pc; - size = 1; + if (kFastUnwindAddPC) { + trace_buffer[0] = pc; + size = 1; + } else { + size = 0; + } if (stack_top < 4096) return; // Sanity check for stack top. uhwptr *frame = GetCanonicFrame(bp, stack_top, stack_bottom); // Lowest possible address that makes sense as the next frame pointer. @@ -81,7 +95,7 @@ while (IsValidFrame((uptr)frame, stack_top, bottom) && IsAligned((uptr)frame, sizeof(*frame)) && size < max_depth) { - uhwptr pc1 = frame[1]; + uhwptr pc1 = frame[kOffsetToPcInFrame]; if (pc1 != pc) { trace_buffer[size++] = (uptr) pc1; } Index: test/asan/TestCases/Linux/malloc_delete_mismatch.cc =================================================================== --- test/asan/TestCases/Linux/malloc_delete_mismatch.cc +++ test/asan/TestCases/Linux/malloc_delete_mismatch.cc @@ -24,10 +24,10 @@ delete x; } // CHECK: ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x -// CHECK-NEXT: #0{{.*}}operator delete +// CHECK: #{{[0-1].*}}operator delete // CHECK: #{{.*}}main // CHECK: is located 0 bytes inside of 10-byte region // CHECK-NEXT: allocated by thread T0 here: -// ALLOC-STACK-NEXT: #0{{.*}}malloc +// ALLOC-STACK: #{{[0-1].*}}malloc // ALLOC-STACK: #{{.*}}main // CHECK: HINT: {{.*}} you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0 Index: test/asan/TestCases/Linux/stack-trace-dlclose.cc =================================================================== --- test/asan/TestCases/Linux/stack-trace-dlclose.cc +++ test/asan/TestCases/Linux/stack-trace-dlclose.cc @@ -40,6 +40,6 @@ } #endif -// CHECK: {{ #0 0x.* in malloc}} -// CHECK: {{ #1 0x.* \(\)}} -// CHECK: {{ #2 0x.* in main}} +// CHECK: {{ #[0-1] 0x.* in malloc}} +// CHECK: {{ #[1-2] 0x.* \(\)}} +// CHECK: {{ #[2-3] 0x.* in main}} Index: test/asan/TestCases/debug_stacks.cc =================================================================== --- test/asan/TestCases/debug_stacks.cc +++ test/asan/TestCases/debug_stacks.cc @@ -55,11 +55,11 @@ // CHECK: ERROR: AddressSanitizer: heap-use-after-free // CHECK: WRITE of size 1 at 0x{{.*}} // CHECK: freed by thread T0 here: - // CHECK: #0 [[FREE_FRAME_0]] - // CHECK: #1 [[FREE_FRAME_1]] + // CHECK: #{{[0-1]}} [[FREE_FRAME_0]] + // CHECK: #{{[1-2]}} [[FREE_FRAME_1]] // CHECK: previously allocated by thread T0 here: - // CHECK: #0 [[ALLOC_FRAME_0]] - // CHECK: #1 [[ALLOC_FRAME_1]] + // CHECK: #{{[0-1]}} [[ALLOC_FRAME_0]] + // CHECK: #{{[1-2]}} [[ALLOC_FRAME_1]] return 0; } Index: test/asan/TestCases/double-free.cc =================================================================== --- test/asan/TestCases/double-free.cc +++ test/asan/TestCases/double-free.cc @@ -16,11 +16,11 @@ free(x); free(x + argc - 1); // BOOM // CHECK: AddressSanitizer: attempting double-free{{.*}}in thread T0 - // CHECK: #0 0x{{.*}} in {{.*}}free - // CHECK: #1 0x{{.*}} in main {{.*}}double-free.cc:[[@LINE-3]] + // CHECK: {{#[0-1] 0x.*}} in {{.*}}free + // CHECK: {{#[1-2] 0x.*}} in main {{.*}}double-free.cc:[[@LINE-3]] // CHECK: freed by thread T0 here: - // MALLOC-CTX: #0 0x{{.*}} in {{.*}}free - // MALLOC-CTX: #1 0x{{.*}} in main {{.*}}double-free.cc:[[@LINE-7]] + // MALLOC-CTX: {{#[0-1] 0x.*}} in {{.*}}free + // MALLOC-CTX: {{#[1-2] 0x.*}} in main {{.*}}double-free.cc:[[@LINE-7]] // CHECK: allocated by thread T0 here: // MALLOC-CTX: double-free.cc:[[@LINE-12]] return res; Index: test/asan/TestCases/heap-overflow.cc =================================================================== --- test/asan/TestCases/heap-overflow.cc +++ test/asan/TestCases/heap-overflow.cc @@ -18,7 +18,7 @@ // CHECK: {{0x.* is located 0 bytes to the right of 10-byte region}} // CHECK: {{allocated by thread T0 here:}} - // CHECK: {{ #0 0x.* in .*malloc}} + // CHECK: {{ #[0-1] 0x.* in .*malloc}} free(x); return res; } Index: test/asan/TestCases/large_func_test.cc =================================================================== --- test/asan/TestCases/large_func_test.cc +++ test/asan/TestCases/large_func_test.cc @@ -25,7 +25,7 @@ x[zero + 103]++; // we should report this exact line // atos incorrectly extracts the symbol name for the static functions on // Darwin. - // CHECK-Linux: {{#0 0x.* in LargeFunction.*large_func_test.cc:}}[[@LINE-3]] + // CHECK-Linux: {{#[0-1] 0x.* in LargeFunction.*large_func_test.cc:}}[[@LINE-3]] // CHECK-Darwin: {{#0 0x.* in .*LargeFunction.*large_func_test.cc}}:[[@LINE-4]] x[10]++; @@ -43,11 +43,11 @@ int main(int argc, char **argv) { int *x = new int[100]; LargeFunction(x, argc - 1); - // CHECK: {{ #1 0x.* in main .*large_func_test.cc:}}[[@LINE-1]] + // CHECK: {{ #[1-2] 0x.* in main .*large_func_test.cc:}}[[@LINE-1]] // CHECK: {{0x.* is located 12 bytes to the right of 400-byte region}} // CHECK: {{allocated by thread T0 here:}} - // CHECK-Linux: {{ #0 0x.* in operator new.*}} + // CHECK-Linux: {{ #[0-1] 0x.* in operator new.*}} // CHECK-Darwin: {{ #0 0x.* in .*_Zna.*}} - // CHECK: {{ #1 0x.* in main .*large_func_test.cc:}}[[@LINE-7]] + // CHECK: {{ #[1-2] 0x.* in main .*large_func_test.cc:}}[[@LINE-7]] delete x; } Index: test/asan/TestCases/strncpy-overflow.cc =================================================================== --- test/asan/TestCases/strncpy-overflow.cc +++ test/asan/TestCases/strncpy-overflow.cc @@ -21,8 +21,8 @@ // CHECK: {{0x.* is located 0 bytes to the right of 9-byte region}} // CHECK: {{allocated by thread T0 here:}} - // CHECK-Linux: {{ #0 0x.* in .*malloc}} - // CHECK-Linux: {{ #1 0x.* in main .*strncpy-overflow.cc:}}[[@LINE-10]] + // CHECK-Linux: {{ #[0-2] 0x.* in .*malloc}} + // CHECK-Linux: {{ #[1-3] 0x.* in main .*strncpy-overflow.cc:}}[[@LINE-10]] // CHECK-Darwin: {{ #0 0x.* in wrap_malloc.*}} // CHECK-Darwin: {{ #1 0x.* in main .*strncpy-overflow.cc:}}[[@LINE-13]] Index: test/asan/TestCases/use-after-delete.cc =================================================================== --- test/asan/TestCases/use-after-delete.cc +++ test/asan/TestCases/use-after-delete.cc @@ -17,13 +17,13 @@ // CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}} // CHECK: {{freed by thread T0 here:}} - // CHECK-Linux: {{ #0 0x.* in operator delete\[\]}} - // CHECK-Linux: {{ #1 0x.* in main .*use-after-delete.cc:}}[[@LINE-10]] + // CHECK-Linux: {{ #[0-1] 0x.* in operator delete\[\]}} + // CHECK-Linux: {{ #[1-2] 0x.* in main .*use-after-delete.cc:}}[[@LINE-10]] // CHECK: {{previously allocated by thread T0 here:}} - // CHECK-Linux: {{ #0 0x.* in operator new\[\]}} - // CHECK-Linux: {{ #1 0x.* in main .*use-after-delete.cc:}}[[@LINE-16]] + // CHECK-Linux: {{ #[0-1] 0x.* in operator new\[\]}} + // CHECK-Linux: {{ #[1-2] 0x.* in main .*use-after-delete.cc:}}[[@LINE-16]] // CHECK: Shadow byte legend (one shadow byte represents 8 application bytes): // CHECK: Global redzone: Index: test/asan/TestCases/use-after-free-right.cc =================================================================== --- test/asan/TestCases/use-after-free-right.cc +++ test/asan/TestCases/use-after-free-right.cc @@ -20,16 +20,16 @@ // CHECK: {{0x.* is located 0 bytes inside of 1-byte region .0x.*,0x.*}} // CHECK: {{freed by thread T0 here:}} - // CHECK-Linux: {{ #0 0x.* in .*free}} - // CHECK-Linux: {{ #1 0x.* in main .*use-after-free-right.cc:}}[[@LINE-10]] + // CHECK-Linux: {{ #[0-1] 0x.* in .*free}} + // CHECK-Linux: {{ #[1-2] 0x.* in main .*use-after-free-right.cc:}}[[@LINE-10]] // CHECK-Darwin: {{ #0 0x.* in wrap_free}} // CHECK-Darwin: {{ #1 0x.* in main .*use-after-free-right.cc:}}[[@LINE-13]] // CHECK: {{previously allocated by thread T0 here:}} - // CHECK-Linux: {{ #0 0x.* in .*malloc}} - // CHECK-Linux: {{ #1 0x.* in main .*use-after-free-right.cc:}}[[@LINE-19]] + // CHECK-Linux: {{ #[0-1] 0x.* in .*malloc}} + // CHECK-Linux: {{ #[1-2] 0x.* in main .*use-after-free-right.cc:}}[[@LINE-19]] // CHECK-Darwin: {{ #0 0x.* in wrap_malloc.*}} // CHECK-Darwin: {{ #1 0x.* in main .*use-after-free-right.cc:}}[[@LINE-22]] Index: test/asan/TestCases/use-after-free.cc =================================================================== --- test/asan/TestCases/use-after-free.cc +++ test/asan/TestCases/use-after-free.cc @@ -17,16 +17,16 @@ // CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}} // CHECK: {{freed by thread T0 here:}} - // CHECK-Linux: {{ #0 0x.* in .*free}} - // CHECK-Linux: {{ #1 0x.* in main .*use-after-free.cc:}}[[@LINE-10]] + // CHECK-Linux: {{ #[0-1] 0x.* in .*free}} + // CHECK-Linux: {{ #[1-2] 0x.* in main .*use-after-free.cc:}}[[@LINE-10]] // CHECK-Darwin: {{ #0 0x.* in wrap_free}} // CHECK-Darwin: {{ #1 0x.* in main .*use-after-free.cc:}}[[@LINE-13]] // CHECK: {{previously allocated by thread T0 here:}} - // CHECK-Linux: {{ #0 0x.* in .*malloc}} - // CHECK-Linux: {{ #1 0x.* in main .*use-after-free.cc:}}[[@LINE-19]] + // CHECK-Linux: {{ #[0-1] 0x.* in .*malloc}} + // CHECK-Linux: {{ #[1-2] 0x.* in main .*use-after-free.cc:}}[[@LINE-19]] // CHECK-Darwin: {{ #0 0x.* in wrap_malloc.*}} // CHECK-Darwin: {{ #1 0x.* in main .*use-after-free.cc:}}[[@LINE-22]]