1// Check that UAR mode can handle very deep recusrion.
2// RUN: %clangxx_asan -O2 %s -o %t
3// RUN: ulimit -s 4096
4// RUN: %env_asan_opts=detect_stack_use_after_return=1 %run %t 2>&1 | FileCheck %s
5
6// Also check that use_sigaltstack+verbosity doesn't crash.
7// RUN: %env_asan_opts=verbosity=1:use_sigaltstack=1:detect_stack_use_after_return=1 %run %t | FileCheck %s
8
9// UNSUPPORTED: ios
10
11#include <stdio.h>
12
13__attribute__((noinline))
14void RecursiveFunc(int depth, int *ptr) {
15 if ((depth % 1000) == 0)
16 printf(format: "[%05d] ptr: %p\n", depth, ptr);
17 if (depth == 0)
18 return;
19 int local;
20 RecursiveFunc(depth: depth - 1, ptr: &local);
21}
22
23int main(int argc, char **argv) {
24 RecursiveFunc(depth: 15000, ptr: 0);
25 return 0;
26}
27// CHECK: [15000] ptr:
28// CHECK: [07000] ptr:
29// CHECK: [00000] ptr:
30

source code of compiler-rt/test/asan/TestCases/Posix/deep_call_stack.cpp