Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | // Check that __asan_poison_memory_region works. |
| 2 | // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s |
| 3 | // |
| 4 | // Check that we can disable it |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 5 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:allow_user_poisoning=0 %run %t |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 6 | |
| 7 | #include <stdlib.h> |
| 8 | |
| 9 | extern "C" void __asan_poison_memory_region(void *, size_t); |
| 10 | |
| 11 | int main(int argc, char **argv) { |
| 12 | char *x = new char[16]; |
| 13 | x[10] = 0; |
| 14 | __asan_poison_memory_region(x, 16); |
| 15 | int res = x[argc * 10]; // BOOOM |
| 16 | // CHECK: ERROR: AddressSanitizer: use-after-poison |
| 17 | // CHECK: main{{.*}}use-after-poison.cc:[[@LINE-2]] |
| 18 | delete [] x; |
| 19 | return res; |
| 20 | } |