raz / test / run / ThreadOverflow.raz

25 lines · 492 B · raw · history · last change 9ca6cfc3

1module ThreadOverflow;
2(* A stack overflow in a thread is told as one in the main thread is:
3 the thread's mapping holds a stack for the signal handlers *)
4import Thread;
5
6proc down(n: I64): I64;
7var pad: [64]I64;
8begin
9 pad[n mod 64] := n;
10 return down(n + 1) + pad[0];
11end;
12
13proc work(_arg: ^U8);
14begin
15 _ := down(0);
16end;
17
18proc main*;
19var t: ^Thread.Thread; e: ERROR;
20begin
21 t, e := Thread.spawn(work, nil);
22 if e = nil then Thread.join(t); end;
23end;
24
25end ThreadOverflow.