1// RUN: %clang_hwasan -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
2// RUN: %clang_hwasan -O3 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
3
4// Stack histories currently are not recorded on x86.
5// XFAIL: target=x86_64{{.*}}
6
7__attribute((noinline)) void buggy() {
8 char c[64];
9 char *volatile p = c;
10 p[65] = 0;
11}
12
13int main() {
14 buggy();
15 // CHECK: WRITE of size 1 at
16 // CHECK: #0 {{.*}} in buggy{{.*}}stack-overflow.c:[[@LINE-6]]
17 // CHECK: Cause: stack tag-mismatch
18 // CHECK: is located in stack of thread
19 // CHECK: Potentially referenced stack objects:
20 // CHECK: Cause: stack-buffer-overflow
21 // CHECK-NEXT: 0x{{.*}} is located 1 bytes after a 64-byte local variable c [0x{{.*}},0x{{.*}}) in buggy {{.*}}stack-overflow.c:
22 // CHECK: Memory tags around the buggy address
23
24 // CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in buggy
25}
26

source code of compiler-rt/test/hwasan/TestCases/stack-overflow.c