Home | History | Annotate | Download | only in solaris
      1 /* Demonstrate Memcheck correctly handling chain of 64 recursive
      2    calls, each of which allocates a 1 M array on the stack.  Requires
      3    --main-stacksize=67117057 (on amd64-linux) or above, but works fine
      4    if you specify that. */
      5 
      6 #include <stdio.h>
      7 
      8 #define N_MBYTES 64
      9 #define N_INTS_PER_MBYTE (1048576 / sizeof(int))
     10 
     11 int rec(int depth)
     12 {
     13    int i, zzz;
     14    int arr[N_INTS_PER_MBYTE];
     15    if (depth == 0) return 0;
     16    for (i = 0; i < N_INTS_PER_MBYTE; i++)
     17       arr[i] = i * depth;
     18    zzz = rec(depth-1);
     19    for (i = 0; i < N_INTS_PER_MBYTE; i++)
     20        zzz += arr[i];
     21    return zzz;
     22 }
     23 
     24 int main(void)
     25 {
     26    int sum;
     27    printf("lsframe2: start\n");
     28    sum = rec(N_MBYTES);
     29    printf("lsframe2: done, result is %d\n", sum);
     30    return 0;
     31 }
     32