flan/test/programs/dev-dyn-trap.flan

35 lines
998 B
Plaintext

;;;; Two dyn values the dyn printer cannot print. [dv] is a dyn view of a Vec
;;;; whose arena was freed, which traps DynRange when printed; the first
;;;; element of [s] is a word that reads as a boxed pointer to address 0x10,
;;;; which faults when printed as a dyn. The inspector hands each to the
;;;; program's own thread to render, so both become a nested break and the
;;;; daemon keeps answering.
(import agent "vendor:agent")
(defstruct Boom [why i32])
(defonce tv (Vec i64))
(defonce dv dyn)
(defonce n i32)
(defn as-dyn [d dyn] dyn d)
(defn inner [s [i64]] i64
(set dv dv) (set n n)
(error (Boom {.why 3}))
(at s 0))
(defn main [] i32
(agent/start "/tmp/flan-dev-dyn-trap-fallback.sock")
(let [ar (arena-new 4096)]
(set tv (vec-new i64 ar))
(push tv 7)
(set dv (as-dyn tv))
(free-all ar))
(set n 5)
(let [v (vec-new i64)]
(push v -1407374883553264)
(push v 5)
(print (inner (slice v))) (println ""))
(dotimes [i 4000] (agent/wait 5))
0)