aboutsummaryrefslogtreecommitdiff
path: root/test/asan/TestCases/Windows/stack_use_after_return.cc
blob: 9c31922af1de5956ac289461f18338d1163d0a4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// RUN: %clang_cl_asan -O0 %s -Fe%t
// RUN: %env_asan_opts=detect_stack_use_after_return=1 not %run %t 2>&1 | FileCheck %s

char *x;

void foo() {
  char stack_buffer[42];
  x = &stack_buffer[13];
}

int main() {
  foo();
  *x = 42;
// CHECK: AddressSanitizer: stack-use-after-return
// CHECK: WRITE of size 1 at {{.*}} thread T0
// CHECK-NEXT: {{#0 0x.* in main .*stack_use_after_return.cc}}:[[@LINE-3]]
//
// CHECK: is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
// CHECK-NEXT: {{#0 0x.* in foo.*stack_use_after_return.cc}}
//
// CHECK: 'stack_buffer' <== Memory access at offset [[OFFSET]] is inside this variable
}