]>
git.saurik.com Git - apple/libpthread.git/blob - tests/helpers/stackoverflow_crash.c
2 #include<sys/resource.h>
4 static volatile int * array1_ref
= NULL
;
5 static long last_stack_addr
= 0;
10 volatile int array1
[1024]; /* leave this as it is */
12 last_stack_addr
= (long)&addr
;
13 array1_ref
= array1
; /* make sure compiler cannot discard storage */
15 if (array1_ref
== 0) {
16 /* fool clang -Winfinite-recursion */
24 main(__unused
int argc
, __unused
const char *argv
[])
28 if (getrlimit(RLIMIT_STACK
, &save
) == -1) {
29 printf("child: ERROR - getrlimit");
32 printf("child: LOG - current stack limits cur=0x%llx, max=0x%llx, inf=0x%llx\n", save
.rlim_cur
, save
.rlim_max
, RLIM_INFINITY
);
34 if(save
.rlim_cur
>= save
.rlim_max
) {
35 printf("child: ERROR - invalid limits");
39 if(save
.rlim_max
== RLIM_INFINITY
) {
40 printf("child: ERROR - rlim_max = RLIM_INFINITY");
46 printf("child: LOG - Raising setrlimit rlim_cur=0x%llx, rlim_max=0x%llx\n", save
.rlim_cur
, save
.rlim_max
);
48 if (setrlimit(RLIMIT_STACK
, &save
) == -1) {
49 printf("child: ERROR - Raising the limits failed.");
53 printf("child: LOG - Make the stack grow such that a SIGSEGV is generated.\n");