Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 1 | // RUN: %clang_cl_asan -O0 %s -Fe%t |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 2 | // RUN: %env_asan_opts=detect_stack_use_after_return=1 not %run %t 2>&1 | FileCheck %s |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 3 | |
| 4 | char *x; |
| 5 | |
| 6 | void foo() { |
| 7 | char stack_buffer[42]; |
| 8 | x = &stack_buffer[13]; |
| 9 | } |
| 10 | |
| 11 | int main() { |
| 12 | foo(); |
| 13 | *x = 42; |
| 14 | // CHECK: AddressSanitizer: stack-use-after-return |
| 15 | // CHECK: WRITE of size 1 at {{.*}} thread T0 |
| 16 | // CHECK-NEXT: {{#0 0x.* in main .*stack_use_after_return.cc}}:[[@LINE-3]] |
| 17 | // |
| 18 | // CHECK: is located in stack of thread T0 at offset [[OFFSET:.*]] in frame |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 19 | // CHECK-NEXT: {{#0 0x.* in foo.*stack_use_after_return.cc}} |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 20 | // |
| 21 | // CHECK: 'stack_buffer' <== Memory access at offset [[OFFSET]] is inside this variable |
| 22 | } |