flan/test/programs/dev-segv.flan

23 lines
1.0 KiB
Plaintext

;;;; The dogfooding crash, replayed on purpose: a store through a pointer to
;;;; a string literal's bytes lands in read-only memory and takes SIGSEGV. In
;;;; a dev session that used to kill the whole process — daemon, compiler and
;;;; socket together, with no message at all. The dev build's crash handler
;;;; turns it into the same park the no-channel traps take: one line naming
;;;; the address and the frame, then the break loop, with the daemon alive
;;;; and answering behind it. There is no restart to list — a faulting
;;;; instruction has nowhere to resume at — which is the same empty-list
;;;; shape dev-trap-null-alloc.flan pins for free-all.
;;;;
;;;; Through a pointer, because a store through the [const u8] itself is
;;;; refused at compile time; a (Ptr T) is the C boundary, where nothing is
;;;; checked.
(import agent "vendor:agent")
(defn main [] i32
(agent/start "/tmp/flan-dev-segv-fallback.sock")
(let [v (bytes-view "INSERTIONSORT")
p (addr (at v 0))]
(set (deref p) \Z)
(print (string v))
0))