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))
RecursiveFunc(int depth,int * ptr)14 void RecursiveFunc(int depth, int *ptr) {
15   if ((depth % 1000) == 0)
16     printf("[%05d] ptr: %p\n", depth, ptr);
17   if (depth == 0)
18     return;
19   int local;
20   RecursiveFunc(depth - 1, &local);
21 }
22 
main(int argc,char ** argv)23 int main(int argc, char **argv) {
24   RecursiveFunc(15000, 0);
25   return 0;
26 }
27 // CHECK: [15000] ptr:
28 // CHECK: [07000] ptr:
29 // CHECK: [00000] ptr:
30