Every stop of a running program exits with status 2; conformance tests for stops, zero start, evaluation order, variant match, defers and Str's byte order
| @@ -0,0 +1,6 @@ | ||
| 1 | +first | |
| 2 | +body | |
| 3 | +second | |
| 4 | +first | |
| 5 | +1 | |
| 6 | +.12 |
| @@ -0,0 +1,41 @@ | ||
| 1 | +(* Only the defers that have been reached run, last first; return | |
| 2 | + evaluates its value before they do. *) | |
| 3 | +module DeferSkip; | |
| 4 | +import Out; | |
| 5 | + | |
| 6 | +proc f(early: BOOL); | |
| 7 | +begin | |
| 8 | + defer Out.str("first\n"); | |
| 9 | + if early then return; end; | |
| 10 | + defer Out.str("second\n"); | |
| 11 | + Out.str("body\n"); | |
| 12 | +end; | |
| 13 | + | |
| 14 | +proc g(): INT; | |
| 15 | +var x: INT; | |
| 16 | +begin | |
| 17 | + x := 1; | |
| 18 | + defer INC(x); | |
| 19 | + return x; | |
| 20 | +end; | |
| 21 | + | |
| 22 | +proc loop; | |
| 23 | +var i: INT; | |
| 24 | +begin | |
| 25 | + for i := 1 to 3 do | |
| 26 | + defer Out.int(i); | |
| 27 | + if i = 2 then break; end; | |
| 28 | + Out.char('.'); | |
| 29 | + end; | |
| 30 | + Out.ln; | |
| 31 | +end; | |
| 32 | + | |
| 33 | +proc main*; | |
| 34 | +begin | |
| 35 | + f(true); | |
| 36 | + f(false); | |
| 37 | + Out.int(g()); Out.ln; | |
| 38 | + loop; | |
| 39 | +end; | |
| 40 | + | |
| 41 | +end DeferSkip. |
| @@ -0,0 +1 @@ | ||
| 1 | +before |
| @@ -0,0 +1,15 @@ | ||
| 1 | +(* A failed check ends the program without running the deferred | |
| 2 | + statements still pending; what the program wrote is still out. *) | |
| 3 | +module DeferStop; | |
| 4 | +import Out; | |
| 5 | + | |
| 6 | +proc main*; | |
| 7 | +var a: [3]I64; i: INT; | |
| 8 | +begin | |
| 9 | + defer Out.str("deferred\n"); | |
| 10 | + Out.str("before\n"); | |
| 11 | + i := ARGC() + 4; | |
| 12 | + Out.int(a[i]); | |
| 13 | +end; | |
| 14 | + | |
| 15 | +end DeferStop. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1,5 @@ | ||
| 1 | +abc | |
| 2 | +abc| | |
| 3 | +ig | |
| 4 | +lh | |
| 5 | +pq! |
| @@ -0,0 +1,34 @@ | ||
| 1 | +(* Operands, arguments and the designators of an assignment are | |
| 2 | + evaluated from left to right, the designators before the right side. *) | |
| 3 | +module EvalOrder; | |
| 4 | +import Out; | |
| 5 | + | |
| 6 | +var t: [4]I64; | |
| 7 | + | |
| 8 | +proc say(c: U8): INT; | |
| 9 | +begin | |
| 10 | + Out.char(c); | |
| 11 | + return 1; | |
| 12 | +end; | |
| 13 | + | |
| 14 | +proc three(_x, _y, _z: INT); | |
| 15 | +begin | |
| 16 | + Out.char('|'); | |
| 17 | +end; | |
| 18 | + | |
| 19 | +proc main*; | |
| 20 | +var x: INT; s: []I64; | |
| 21 | +begin | |
| 22 | + x := say('a') + say('b') * say('c'); | |
| 23 | + Out.ln; | |
| 24 | + three(say('a'), say('b'), say('c')); | |
| 25 | + Out.ln; | |
| 26 | + t[say('i')] := say('g'); | |
| 27 | + Out.ln; | |
| 28 | + s := t[say('l') - 1 .. say('h') + 1]; | |
| 29 | + Out.ln; | |
| 30 | + if (say('p') = 1) and (say('q') = 1) then Out.char('!'); end; | |
| 31 | + Out.ln; | |
| 32 | +end; | |
| 33 | + | |
| 34 | +end EvalOrder. |
| @@ -0,0 +1,2 @@ | ||
| 1 | +an instance of Loud, of size 8 | |
| 2 | +sizes 8 8 |
| @@ -0,0 +1,11 @@ | ||
| 1 | +(* The body of a generic module runs once for an instance, however | |
| 2 | + many times it is imported. *) | |
| 3 | +module LoudOnce; | |
| 4 | +import Out, A := Loud(I64), B := Loud(I64); | |
| 5 | + | |
| 6 | +proc main*; | |
| 7 | +begin | |
| 8 | + Out.str("sizes "); Out.int(A.size); Out.char(' '); Out.int(B.size); Out.ln; | |
| 9 | +end; | |
| 10 | + | |
| 11 | +end LoudOnce. |
| @@ -0,0 +1,2 @@ | ||
| 1 | +before | |
| 2 | +bye |
| @@ -0,0 +1,22 @@ | ||
| 1 | +(* Dividing the smallest I64 by -1 stops the program. The program ends with status 2, after the procedures registered | |
| 2 | + with Rt.atExit, so that what it wrote is out. *) | |
| 3 | +module StopDivLowest; | |
| 4 | +import Out, Rt; | |
| 5 | + | |
| 6 | + | |
| 7 | +proc bye; | |
| 8 | +begin | |
| 9 | + Out.str("bye\n"); | |
| 10 | +end; | |
| 11 | + | |
| 12 | +proc main*; | |
| 13 | +var a, b: I64; | |
| 14 | +begin | |
| 15 | + _ := Rt.atExit(bye); | |
| 16 | + a := -9223372036854775807 - 1; | |
| 17 | + b := -1; | |
| 18 | + Out.str("before\n"); | |
| 19 | + Out.int(a div b); | |
| 20 | +end; | |
| 21 | + | |
| 22 | +end StopDivLowest. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1,2 @@ | ||
| 1 | +before | |
| 2 | +bye |
| @@ -0,0 +1,22 @@ | ||
| 1 | +(* Dividing by zero stops the program. The program ends with status 2, after the procedures registered | |
| 2 | + with Rt.atExit, so that what it wrote is out. *) | |
| 3 | +module StopDivZero; | |
| 4 | +import Out, Rt; | |
| 5 | + | |
| 6 | + | |
| 7 | +proc bye; | |
| 8 | +begin | |
| 9 | + Out.str("bye\n"); | |
| 10 | +end; | |
| 11 | + | |
| 12 | +proc main*; | |
| 13 | +var a, b: I64; | |
| 14 | +begin | |
| 15 | + _ := Rt.atExit(bye); | |
| 16 | + a := 7; | |
| 17 | + b := ARGC() - 1; | |
| 18 | + Out.str("before\n"); | |
| 19 | + Out.int(a div b); | |
| 20 | +end; | |
| 21 | + | |
| 22 | +end StopDivZero. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1,2 @@ | ||
| 1 | +before | |
| 2 | +bye |
| @@ -0,0 +1,22 @@ | ||
| 1 | +(* Following nil stops the program. The program ends with status 2, after the procedures registered | |
| 2 | + with Rt.atExit, so that what it wrote is out. *) | |
| 3 | +module StopNil; | |
| 4 | +import Out, Rt; | |
| 5 | + | |
| 6 | +type Cell = record next: ^Cell; v: I64; end; | |
| 7 | + | |
| 8 | +proc bye; | |
| 9 | +begin | |
| 10 | + Out.str("bye\n"); | |
| 11 | +end; | |
| 12 | + | |
| 13 | +proc main*; | |
| 14 | +var c: Cell; | |
| 15 | +begin | |
| 16 | + _ := Rt.atExit(bye); | |
| 17 | + c.v := 1; | |
| 18 | + Out.str("before\n"); | |
| 19 | + Out.int(c.next^.v); | |
| 20 | +end; | |
| 21 | + | |
| 22 | +end StopNil. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1,2 @@ | ||
| 1 | +before | |
| 2 | +bye |
| @@ -0,0 +1,20 @@ | ||
| 1 | +(* Calling a nil procedure stops the program. The program ends with status 2, after the procedures registered | |
| 2 | + with Rt.atExit, so that what it wrote is out. *) | |
| 3 | +module StopNilProc; | |
| 4 | +import Out, Rt; | |
| 5 | + | |
| 6 | + | |
| 7 | +proc bye; | |
| 8 | +begin | |
| 9 | + Out.str("bye\n"); | |
| 10 | +end; | |
| 11 | + | |
| 12 | +proc main*; | |
| 13 | +var p: proc; | |
| 14 | +begin | |
| 15 | + _ := Rt.atExit(bye); | |
| 16 | + Out.str("before\n"); | |
| 17 | + p(); | |
| 18 | +end; | |
| 19 | + | |
| 20 | +end StopNilProc. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1,2 @@ | ||
| 1 | +before | |
| 2 | +bye |
| @@ -0,0 +1,27 @@ | ||
| 1 | +(* Running out of stack stops the program. The program ends with status 2, after the procedures registered | |
| 2 | + with Rt.atExit, so that what it wrote is out. *) | |
| 3 | +module StopStack; | |
| 4 | +import Out, Rt; | |
| 5 | + | |
| 6 | +proc down(n: INT): INT; | |
| 7 | +var pad: [65536]INT; | |
| 8 | +begin | |
| 9 | + pad[n mod 65536] := n; | |
| 10 | + return down(n + 1) + pad[0]; | |
| 11 | +end; | |
| 12 | + | |
| 13 | +proc bye; | |
| 14 | +begin | |
| 15 | + Out.str("bye\n"); | |
| 16 | +end; | |
| 17 | + | |
| 18 | +proc main*; | |
| 19 | +var n: INT; | |
| 20 | +begin | |
| 21 | + _ := Rt.atExit(bye); | |
| 22 | + Out.str("before\n"); | |
| 23 | + n := down(0); | |
| 24 | + Out.int(n); | |
| 25 | +end; | |
| 26 | + | |
| 27 | +end StopStack. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1,9 @@ | ||
| 1 | +8 7 6 5 4 3 2 1 | |
| 2 | +1 2 3 4 5 6 7 8 | |
| 3 | +578437695752307201 | |
| 4 | +72623859790382856 | |
| 5 | +2 1 | |
| 6 | +258 | |
| 7 | +513 | |
| 8 | +0 | |
| 9 | +204 187 170 |
| @@ -0,0 +1,34 @@ | ||
| 1 | +(* Str's byte order: le and be read, putLE and putBE write, a number | |
| 2 | + of up to 8 bytes, whatever the machine's own order. *) | |
| 3 | +module StrBytes; | |
| 4 | +import Out, Str; | |
| 5 | + | |
| 6 | +proc bytes(s: []U8); | |
| 7 | +var i: INT; | |
| 8 | +begin | |
| 9 | + for i := 0 to LEN(s) - 1 do | |
| 10 | + if i > 0 then Out.char(' '); end; | |
| 11 | + Out.int(I64(s[i])); | |
| 12 | + end; | |
| 13 | + Out.ln; | |
| 14 | +end; | |
| 15 | + | |
| 16 | +proc main*; | |
| 17 | +var b: [8]U8; | |
| 18 | +begin | |
| 19 | + Str.putLE(b[0..8], 0102030405060708H); | |
| 20 | + bytes(b[0..8]); | |
| 21 | + Str.putBE(b[0..8], 0102030405060708H); | |
| 22 | + bytes(b[0..8]); | |
| 23 | + Out.int(I64(Str.le(b[0..8]))); Out.ln; | |
| 24 | + Out.int(I64(Str.be(b[0..8]))); Out.ln; | |
| 25 | + Str.putBE(b[0..2], 513); | |
| 26 | + bytes(b[0..2]); | |
| 27 | + Out.int(I64(Str.le(b[0..2]))); Out.ln; | |
| 28 | + Out.int(I64(Str.be(b[0..2]))); Out.ln; | |
| 29 | + Out.int(I64(Str.le(b[0..0]))); Out.ln; | |
| 30 | + Str.putLE(b[0..3], 0AABBCCH); | |
| 31 | + bytes(b[0..3]); | |
| 32 | +end; | |
| 33 | + | |
| 34 | +end StrBytes. |
| @@ -0,0 +1 @@ | ||
| 1 | +before |
| @@ -0,0 +1,13 @@ | ||
| 1 | +(* putLE and putBE write at most 8 bytes: more stops the program. *) | |
| 2 | +module StrBytesStop; | |
| 3 | +import Out, Str; | |
| 4 | + | |
| 5 | +proc main*; | |
| 6 | +var b: [9]U8; | |
| 7 | +begin | |
| 8 | + Out.str("before\n"); | |
| 9 | + Str.putLE(b[0..9], 1); | |
| 10 | + Out.str("after\n"); | |
| 11 | +end; | |
| 12 | + | |
| 13 | +end StrBytesStop. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1,14 @@ | ||
| 1 | +pair 30 5 | |
| 2 | +pair 30 5 | |
| 3 | +unnamed | |
| 4 | +none | |
| 5 | +num 5 | |
| 6 | +additive | |
| 7 | +additive | |
| 8 | +times | |
| 9 | +other | |
| 10 | +zero | |
| 11 | +small | |
| 12 | +negative or ten | |
| 13 | +negative or ten | |
| 14 | +big |
| @@ -0,0 +1,74 @@ | ||
| 1 | +(* match: the names of an arm stand for the fields of the variant | |
| 2 | + itself when it is a variable, and for a copy when it isn't. *) | |
| 3 | +module VariantMatch; | |
| 4 | +import Out; | |
| 5 | + | |
| 6 | +type | |
| 7 | + Shape = variant num(n: I64); pair(a, b: I64); none; end; | |
| 8 | + Op = (plus, minus, times, divide); | |
| 9 | + | |
| 10 | +var g: Shape; | |
| 11 | + | |
| 12 | +proc copyOfG(): Shape; | |
| 13 | +begin | |
| 14 | + return g; | |
| 15 | +end; | |
| 16 | + | |
| 17 | +proc show(s: Shape); | |
| 18 | +begin | |
| 19 | + match s of | |
| 20 | + | num(n): Out.str("num "); Out.int(n); | |
| 21 | + | pair(a, b): Out.str("pair "); Out.int(a); Out.char(' '); Out.int(b); | |
| 22 | + | none: Out.str("none"); | |
| 23 | + end; | |
| 24 | + Out.ln; | |
| 25 | +end; | |
| 26 | + | |
| 27 | +proc kind(op: Op); | |
| 28 | +begin | |
| 29 | + match op of | |
| 30 | + | plus, minus: Out.str("additive"); | |
| 31 | + | times: Out.str("times"); | |
| 32 | + | else: Out.str("other"); | |
| 33 | + end; | |
| 34 | + Out.ln; | |
| 35 | +end; | |
| 36 | + | |
| 37 | +proc size(n: I64); | |
| 38 | +begin | |
| 39 | + match n of | |
| 40 | + | 0: Out.str("zero"); | |
| 41 | + | 1 .. 9: Out.str("small"); | |
| 42 | + | -5 .. -1, 10: Out.str("negative or ten"); | |
| 43 | + | else: Out.str("big"); | |
| 44 | + end; | |
| 45 | + Out.ln; | |
| 46 | +end; | |
| 47 | + | |
| 48 | +proc main*; | |
| 49 | +begin | |
| 50 | + g := pair(3, 4); | |
| 51 | + match g of | |
| 52 | + | pair(a, b): a := a * 10; INC(b); (* through the names: g changes *) | |
| 53 | + | else: | |
| 54 | + end; | |
| 55 | + show(g); | |
| 56 | + match copyOfG() of | |
| 57 | + | pair(a, b): a := 0; b := 0; (* a copy: g does not change *) | |
| 58 | + | else: | |
| 59 | + end; | |
| 60 | + show(g); | |
| 61 | + match g of | |
| 62 | + | num: Out.str("no\n"); (* fields left unnamed *) | |
| 63 | + | pair: Out.str("unnamed\n"); | |
| 64 | + | none: Out.str("no\n"); | |
| 65 | + end; | |
| 66 | + g := none; | |
| 67 | + show(g); | |
| 68 | + g := num(5); | |
| 69 | + show(g); | |
| 70 | + kind(plus); kind(minus); kind(times); kind(divide); | |
| 71 | + size(0); size(5); size(-3); size(10); size(11); | |
| 72 | +end; | |
| 73 | + | |
| 74 | +end VariantMatch. |
| @@ -0,0 +1,16 @@ | ||
| 1 | +number zero | |
| 2 | +bool zero | |
| 3 | +pointers zero | |
| 4 | +slice zero | |
| 5 | +enumeration and set zero | |
| 6 | +record zero | |
| 7 | +array zero | |
| 8 | +variant first 0 | |
| 9 | +local number zero | |
| 10 | +local bool zero | |
| 11 | +local pointers zero | |
| 12 | +local slice zero | |
| 13 | +local enumeration and set zero | |
| 14 | +local record zero | |
| 15 | +local array zero | |
| 16 | +local variant first 0 |
| @@ -0,0 +1,69 @@ | ||
| 1 | +(* Every variable starts at zero: a module's, and a procedure's even | |
| 2 | + where the stack held other values before. *) | |
| 3 | +module ZeroStart; | |
| 4 | +import Out; | |
| 5 | + | |
| 6 | +type | |
| 7 | + Colour = (red, green, blue); | |
| 8 | + Flags = set of Colour; | |
| 9 | + Rec = record n: I64; ok: BOOL; p: ^Rec; end; | |
| 10 | + Shape = variant first(x: I64); second(y: I64); end; | |
| 11 | + | |
| 12 | +var | |
| 13 | + n: I64; u: U8; ok: BOOL; p: ^Rec; f: proc; e: ERROR; s: []U8; | |
| 14 | + c: Colour; fl: Flags; r: Rec; a: [3]I64; v: Shape; | |
| 15 | + | |
| 16 | +proc line(name: []U8; zero: BOOL); | |
| 17 | +begin | |
| 18 | + Out.str(name); | |
| 19 | + if zero then Out.str(" zero"); else Out.str(" NOT ZERO"); end; | |
| 20 | + Out.ln; | |
| 21 | +end; | |
| 22 | + | |
| 23 | +proc which(name: []U8; v: Shape); | |
| 24 | +begin | |
| 25 | + Out.str(name); | |
| 26 | + match v of | |
| 27 | + | first(x): Out.str(" first "); Out.int(x); | |
| 28 | + | second(y): Out.str(" second "); Out.int(y); | |
| 29 | + end; | |
| 30 | + Out.ln; | |
| 31 | +end; | |
| 32 | + | |
| 33 | +(* leaves its frame full of other values *) | |
| 34 | +proc dirty; | |
| 35 | +var pad: [64]I64; i: INT; | |
| 36 | +begin | |
| 37 | + for i := 0 to 63 do pad[i] := 7; end; | |
| 38 | +end; | |
| 39 | + | |
| 40 | +proc locals; | |
| 41 | +var | |
| 42 | + n: I64; u: U8; ok: BOOL; p: ^Rec; f: proc; e: ERROR; s: []U8; | |
| 43 | + c: Colour; fl: Flags; r: Rec; a: [3]I64; v: Shape; | |
| 44 | +begin | |
| 45 | + line("local number", (n = 0) and (u = 0)); | |
| 46 | + line("local bool", not ok); | |
| 47 | + line("local pointers", (p = nil) and (f = nil) and (e = nil)); | |
| 48 | + line("local slice", LEN(s) = 0); | |
| 49 | + line("local enumeration and set", (c = red) and not (red in fl) and not (blue in fl)); | |
| 50 | + line("local record", (r.n = 0) and not r.ok and (r.p = nil)); | |
| 51 | + line("local array", (a[0] = 0) and (a[1] = 0) and (a[2] = 0)); | |
| 52 | + which("local variant", v); | |
| 53 | +end; | |
| 54 | + | |
| 55 | +proc main*; | |
| 56 | +begin | |
| 57 | + line("number", (n = 0) and (u = 0)); | |
| 58 | + line("bool", not ok); | |
| 59 | + line("pointers", (p = nil) and (f = nil) and (e = nil)); | |
| 60 | + line("slice", LEN(s) = 0); | |
| 61 | + line("enumeration and set", (c = red) and not (red in fl) and not (blue in fl)); | |
| 62 | + line("record", (r.n = 0) and not r.ok and (r.p = nil)); | |
| 63 | + line("array", (a[0] = 0) and (a[1] = 0) and (a[2] = 0)); | |
| 64 | + which("variant", v); | |
| 65 | + dirty; | |
| 66 | + locals; | |
| 67 | +end; | |
| 68 | + | |
| 69 | +end ZeroStart. |
| @@ -1483,9 +1483,9 @@ | ||
| 1483 | 1483 | the program by `Rt.exit` with status 2; `Rt.stop` says its message |
| 1484 | 1484 | and ends it the same way. A signal |
| 1485 | 1485 | is told at the place of the statement it stopped in, or of the |
| 1486 | - procedure for a stack overflow in its prologue, and then ends the | |
| 1487 | - program as the report says, with status 2 (until `Rt`'s handlers | |
| 1488 | - do so, its status is the signal's). The handlers run on a stack | |
| 1486 | + procedure for a stack overflow in its prologue, and then `Rt.exit` | |
| 1487 | + ends the program with status 2, after the procedures registered with | |
| 1488 | + `Rt.atExit`, as for a failed check. The handlers run on a stack | |
| 1489 | 1489 | of their own: `Rt`'s for the main thread, one in each `Thread` |
| 1490 | 1490 | thread's mapping. C's threads have none, so a stack overflow in one |
| 1491 | 1491 | ends the program by the signal with no message. |
| @@ -539,27 +539,23 @@ | ||
| 539 | 539 | the enumeration called name; 3 for a slice a..b of a pointer, which |
| 540 | 540 | runs backwards. What a target's machine doesn't catch the code |
| 541 | 541 | tests for, and stops at with what 4, a nil pointer; 5, a division |
| 542 | - by zero; 6, a stack overflow; these end the program by the signal | |
| 543 | - the machine would have given, as if it had. rdi and rsi are the | |
| 542 | + by zero; 6, a stack overflow; these end the program by exit with | |
| 543 | + status 2 too, as the signal handler does. rdi and rsi are the | |
| 544 | 544 | registers as the failing code had them. *) |
| 545 | 545 | proc fail*(what, a, b, len: INT; at: UINT; name: ^U8; rdi, rsi: UINT); |
| 546 | -var sig: INT; | |
| 547 | 546 | begin |
| 548 | 547 | regs[5] := rdi; |
| 549 | 548 | regs[6] := rsi; |
| 550 | 549 | where(at); |
| 551 | 550 | if what >= 4 then |
| 552 | 551 | put("stopped by "); |
| 553 | - sig := SigSegv; | |
| 554 | 552 | if what = 4 then put("a nil pointer"); |
| 555 | - elsif what = 5 then put("a division fault"); sig := SigFpe; | |
| 553 | + elsif what = 5 then put("a division fault"); | |
| 556 | 554 | else put("a stack overflow"); |
| 557 | 555 | end; |
| 558 | 556 | say; |
| 559 | 557 | if teller # nil then teller(at, callerFrame(), true); end; |
| 560 | - act := {}; (* the signal's default action *) | |
| 561 | - _ := SYSCALL(13, sig, ADR(act), 0, 8); (* rt_sigaction *) | |
| 562 | - _ := SYSCALL(62, SYSCALL(39), sig); (* kill(getpid(), sig) *) | |
| 558 | + exit(2); | |
| 563 | 559 | end; |
| 564 | 560 | if what = 0 then |
| 565 | 561 | put("index "); |
| @@ -592,10 +588,8 @@ | ||
| 592 | 588 | end sigReturn; |
| 593 | 589 | |
| 594 | 590 | (* A signal stops the program: says where it was and why on standard |
| 595 | - error, and returns to the instruction that faulted. The handler was | |
| 596 | - reset as it was called, so the instruction faults again and the | |
| 597 | - signal ends the program. info and ctx are the kernel's siginfo and | |
| 598 | - ucontext. *) | |
| 591 | + error, then ends the program by exit with status 2, as a failed | |
| 592 | + check does. info and ctx are the kernel's siginfo and ucontext. *) | |
| 599 | 593 | proc onSignal(sig: INT; info, ctx: ^U8); |
| 600 | 594 | var adr, sp, ip, bp: UINT; q: ^UINT; why: []U8; |
| 601 | 595 | begin |
| @@ -623,6 +617,7 @@ | ||
| 623 | 617 | say; |
| 624 | 618 | (* the variables of a frame the stack overflowed in may be past it *) |
| 625 | 619 | if teller # nil then teller(ip, bp, why # "a stack overflow"); end; |
| 620 | + exit(2); | |
| 626 | 621 | end; |
| 627 | 622 | |
| 628 | 623 | (* Whether a is in the program's own code, not C's *) |
| @@ -1 +1 @@ | ||
| 1 | -139 | |
| 1 | +2 |
| @@ -1 +1 @@ | ||
| 1 | -136 | |
| 1 | +2 |
| @@ -1 +1 @@ | ||
| 1 | -136 | |
| 1 | +2 |
| @@ -1 +1 @@ | ||
| 1 | -136 | |
| 1 | +2 |
| @@ -1 +1 @@ | ||
| 1 | -136 | |
| 1 | +2 |
| @@ -1 +1 @@ | ||
| 1 | -136 | |
| 1 | +2 |
| @@ -0,0 +1 @@ | ||
| 1 | +3 |
| @@ -1 +1 @@ | ||
| 1 | -139 | |
| 1 | +2 |
| @@ -1 +1 @@ | ||
| 1 | -139 | |
| 1 | +2 |
| @@ -1 +1 @@ | ||
| 1 | -139 | |
| 1 | +2 |
| @@ -1 +1 @@ | ||
| 1 | -139 | |
| 1 | +2 |
| @@ -1 +1 @@ | ||
| 1 | -139 | |
| 1 | +2 |
| @@ -1 +1 @@ | ||
| 1 | -139 | |
| 1 | +2 |