flan/spike/x86/p11-reversed-slice.flan
Joseph Ferano 2e203f64b8 bytes copies, bytes-view aliases, and a dev-session segfault parks
The INSERTIONSORT crash, all three rulings (FIX.org 2026-09-20):

- (bytes s) allocates a writable copy through the allocator surface —
  context or (bytes s a), StorageExhausted with retry, a registry note in
  dev builds (flan_bytes_dup, lowered like vec-new). (bytes-view s) is the
  old zero-cost reinterpret, renamed, read-only by convention; every
  in-repo reader swept over to it. (string b) unchanged.
- String constants were already read-only on both backends at -O0; now
  pinned — bytes-copy.flan rows on LLVM/-O0/--x86, and dies_segv rows
  asserting the write-through-view trap on both backends.
- A dev build installs a SIGSEGV/SIGBUS handler by the same dev-only
  constructor slot that arms the registry: one line naming the address and
  the innermost frame, then the trap-hook park — stopped, not dead, the
  daemon serving. No agent: message and re-raise. Release builds untouched.
  Pinned by trap_park over dev-segv.flan.
2026-09-20 23:12:42 +07:00

27 lines
1.3 KiB
Plaintext

;;;; A slice built backwards, for the survey rather than for a person.
;;;;
;;;; test/programs/bounds.flan already covers this, and cannot cover it here:
;;;; it picks its case out of (at args 1) and survey.sh runs every program
;;;; with no arguments at all. So the one backend comparison that would catch
;;;; check_slice's lo <= hi being re-gated on --no-bounds-checks is a program
;;;; that reaches the reversed slice on its own.
;;;;
;;;; What it pins is that both backends die here in *every* build. lo <= hi is
;;;; not a bounds check — it is the claim that the length word of the %slice
;;;; this expression builds is a count, and hi - lo is -1 — so
;;;; --no-bounds-checks has nothing here to drop, and running this sweep with
;;;; SURVEY_FLAGS=--no-bounds-checks must report the same MATCH as without it.
;;;; A backend that quietly builds the slice exits 0 while the other exits 134
;;;; and the survey says DIFFER.
;;;;
;;;; The two ends come from (len args), which is 1 for a program run with no
;;;; arguments and is not a number either optimiser can see, so the branch
;;;; cannot be folded away and the checker has no literal to object to.
(defn main [args [string]] i32
(let [s (bytes-view "hello")
hi (i32 (len args))
lo (+ hi 1)]
(print (slice s lo hi))
(println ""))
0)