| 1 | module 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 | |
| 7 | proc down(n: INT): INT; |
| 8 | var pad: [65536]INT; |
| 9 | begin |
| 10 | pad[n mod 65536] := n; |
| 11 | return down(n + 1) + pad[0]; |
| 12 | end; |
| 13 | |
| 14 | proc main*: INT; |
| 15 | begin |
| 16 | return down(0); |
| 17 | end; |
| 18 | |
| 19 | end StackOverflow. |