nx_probe_crashstk_live.nx source
↩ module page · 17 lines · 763 B
1// nx_probe_crashstk_live.nx -- WITNESS: a STACK-OVERFLOW crash under the guard must still print
2// the diagnostic (proves the alternate signal stack works -- without sigaltstack the handler
3// frame cannot be pushed and the process dies silently) and still die by the original signal.
4// The recursion is deliberately NOT a tail call (the add uses the recursive result) so the
5// frames genuinely accumulate. The gate asserts: exit 139 AND stderr contains "the program
6// crashed" (fault address is the guard page -- not assertable exactly, unlike the null probe).
7import "nx_crash.nx"
8
9func crashstk_rec(n: i64) -> i64 {
10 let a: i64 = crashstk_rec(n + 1)
11 return a + n
12}
13
14func main(argc: i64, argv: *u8) -> i64 {
15 nx_crash_guard()
16 return crashstk_rec(0)
17}