1 // RUN: %clang_hwasan -O1 %s -o %t
2 // RUN: %env_hwasan_opts=stack_history_size=1 not %run %t 2>&1 | FileCheck %s --check-prefix=D1
3 // RUN: %env_hwasan_opts=stack_history_size=2 not %run %t 2>&1 | FileCheck %s --check-prefix=D2
4 // RUN: %env_hwasan_opts=stack_history_size=3 not %run %t 2>&1 | FileCheck %s --check-prefix=D3
5 // RUN: %env_hwasan_opts=stack_history_size=5 not %run %t 2>&1 | FileCheck %s --check-prefix=D5
6 // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=DEFAULT
8 // REQUIRES: stable-runtime
11 // At least -O1 is needed for this function to not have a stack frame on
13 void USE(void *x) { // pretend_to_do_something(void *x)
14 __asm__ __volatile__("" : : "r" (x) : "memory");
17 volatile int four = 4;
19 __attribute__((noinline)) void OOB() { int x[4]; x[four] = 0; USE(&x[0]); }
20 __attribute__((noinline)) void FUNC1() { int x; USE(&x); OOB(); }
21 __attribute__((noinline)) void FUNC2() { int x; USE(&x); FUNC1(); }
22 __attribute__((noinline)) void FUNC3() { int x; USE(&x); FUNC2(); }
23 __attribute__((noinline)) void FUNC4() { int x; USE(&x); FUNC3(); }
24 __attribute__((noinline)) void FUNC5() { int x; USE(&x); FUNC4(); }
25 __attribute__((noinline)) void FUNC6() { int x; USE(&x); FUNC5(); }
26 __attribute__((noinline)) void FUNC7() { int x; USE(&x); FUNC6(); }
27 __attribute__((noinline)) void FUNC8() { int x; USE(&x); FUNC7(); }
28 __attribute__((noinline)) void FUNC9() { int x; USE(&x); FUNC8(); }
29 __attribute__((noinline)) void FUNC10() { int x; USE(&x); FUNC9(); }
31 int main() { FUNC10(); }
33 // D1: Previously allocated frames
36 // D1: Memory tags around the buggy address
38 // D2: Previously allocated frames
42 // D2: Memory tags around the buggy address
44 // D3: Previously allocated frames
49 // D3: Memory tags around the buggy address
51 // D5: Previously allocated frames
58 // D5: Memory tags around the buggy address
60 // DEFAULT: Previously allocated frames
72 // DEFAULT-NOT: in FUNC
73 // DEFAULT: Memory tags around the buggy address