28 lines · cpp
1// Test line numbers in signal handlers2// Fails with debug checks: https://bugs.llvm.org/show_bug.cgi?id=468603// XFAIL: !compiler-rt-optimized && tsan4 5// RUN: %clangxx %s -o %t -O06// RUN: %env_tool_opts=handle_segv=1:print_stacktrace=1 not %run %t 1 2>&1 | FileCheck --check-prefixes=CHECK1,CHECK %s7// RUN: %env_tool_opts=handle_segv=1:print_stacktrace=1 not %run %t 2 2>&1 | FileCheck --check-prefixes=CHECK2,CHECK %s8 9#include <cstdio>10#include <string>11 12// CHECK: [[SAN:.*Sanitizer]]:DEADLYSIGNAL13// CHECK: ERROR: [[SAN]]: SEGV on unknown address {{0x[^ ]*}} (pc14int main(int argc, char **argv) {15 int n = atoi(argv[1]);16 17 if (n == 1)18 *((volatile int *)0x0) = __LINE__;19 // CHECK1: #{{[0-9]+ .*}}main {{.*}}signal_line.cpp:[[@LINE-1]]:[[TAB:[0-9]+]]20 // CHECK1: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main21 22 if (n == 2)23 // Allow for strict-alignment targets that require natural alignment.24 *((volatile int *)0x8) = __LINE__;25 // CHECK2: #{{[0-9]+ .*}}main {{.*}}signal_line.cpp:[[@LINE-1]]:[[TAB:[0-9]+]]26 // CHECK2: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main27}28