raz / test / run / StackOverflow.raz

19 lines · 479 B · raw · history · last change 2411fde8

1module StackOverflow;
2(* A recursion with no end runs out of stack: SIGSEGV, said as such.
3 The frame is big so that the fault lands in the prologue, which
4 zeroes it from the bottom: with a small one, where the stack starts
5 could put the guard page under the body's pushes instead. *)
6
7proc down(n: INT): INT;
8var pad: [65536]INT;
9begin
10 pad[n mod 65536] := n;
11 return down(n + 1) + pad[0];
12end;
13
14proc main*: INT;
15begin
16 return down(0);
17end;
18
19end StackOverflow.