1 | // Test the handle_sigill option. |
2 | // |
3 | // RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=0 not --crash %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0 |
4 | // RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 |
5 | // REQUIRES: x86-target-arch |
6 | |
7 | #ifdef _WIN32 |
8 | #include <windows.h> |
9 | #endif |
10 | |
11 | int main(int argc, char **argv) { |
12 | #ifdef _WIN32 |
13 | // Sometimes on Windows this test generates a WER fault dialog. Suppress that. |
14 | UINT new_flags = SEM_FAILCRITICALERRORS | |
15 | SEM_NOGPFAULTERRORBOX | |
16 | SEM_NOOPENFILEERRORBOX; |
17 | // Preserve existing error mode, as discussed at |
18 | // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx |
19 | UINT existing_flags = SetErrorMode(new_flags); |
20 | SetErrorMode(existing_flags | new_flags); |
21 | #endif |
22 | |
23 | if (argc) |
24 | __builtin_trap(); |
25 | // Unreachable code to avoid confusing the Windows unwinder. |
26 | #ifdef _WIN32 |
27 | SetErrorMode(0); |
28 | #endif |
29 | } |
30 | // CHECK0-NOT: ERROR: AddressSanitizer |
31 | // CHECK1: ERROR: AddressSanitizer: {{ILL|illegal-instruction}} on unknown address {{0x0*}} |
32 | |