1 | // RUN: %clangxx_asan -O %s -o %t && %run %t |
---|---|
2 | |
3 | // FIXME: merge this with the common longjmp test when we can run common |
4 | // tests on Windows. |
5 | |
6 | #include <assert.h> |
7 | #include <setjmp.h> |
8 | #include <stdio.h> |
9 | #include <sanitizer/asan_interface.h> |
10 | |
11 | static jmp_buf buf; |
12 | |
13 | int main() { |
14 | char x[32]; |
15 | fprintf(stderr, format: "\nTestLongJmp\n"); |
16 | fprintf(stderr, format: "Before: %p poisoned: %d\n", &x, |
17 | __asan_address_is_poisoned(addr: x + 32)); |
18 | assert(__asan_address_is_poisoned(x + 32)); |
19 | if (0 == setjmp(buf)) |
20 | longjmp(env: buf, val: 1); |
21 | fprintf(stderr, format: "After: %p poisoned: %d\n", &x, |
22 | __asan_address_is_poisoned(addr: x + 32)); |
23 | // FIXME: Invert this assertion once we fix |
24 | // https://code.google.com/p/address-sanitizer/issues/detail?id=258 |
25 | assert(!__asan_address_is_poisoned(x + 32)); |
26 | } |
27 |