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