28 lines
942 B
Plaintext
28 lines
942 B
Plaintext
;;;; The message a handler for a parent reads lives in context/temp, so it is
|
|
;;;; good until the frame ends, not only while the clause runs: [why] hands it
|
|
;;;; back to its caller, which writes over the stack before printing it. Kept
|
|
;;;; past (free-temp) without a clone, a dev build has poisoned it with
|
|
;;;; 0xDEADBEEF, so its first byte is one of that pattern's; a release build
|
|
;;;; still has "(" there.
|
|
|
|
(defstruct MyErr :parent Error [code i32])
|
|
|
|
(defn why [] string
|
|
(handler-case (do (error (MyErr {.code 3})) "")
|
|
[(Error [e] (.message e))]))
|
|
|
|
(defn scribble [n i32] i64
|
|
(let [junk (array-fill [64] (i64 n))]
|
|
(if (= n 0) (at junk 3) (+ (at junk 5) (scribble (- n 1))))))
|
|
|
|
(defn main [] i32
|
|
(let [m (why)]
|
|
(scribble 40)
|
|
(println m))
|
|
(let [m (why)]
|
|
(free-temp)
|
|
(let [b (at (bytes-view m) 0)]
|
|
(println (or (= b (u8 0xEF)) (= b (u8 0xBE)) (= b (u8 0xAD))
|
|
(= b (u8 0xDE))))))
|
|
0)
|