20 lines
750 B
Plaintext
20 lines
750 B
Plaintext
;;;; A slice taken before a push moved the Vec's storage still points at the
|
|
;;;; old block. In a dev build that block is filled with 0xDEADBEEF words when
|
|
;;;; the move happens, so the stale read shows a value nobody wrote; a release
|
|
;;;; build leaves the old values where they were.
|
|
;;;;
|
|
;;;; The Vec lives in an arena so the old block stays mapped and the read is of
|
|
;;;; live memory. A second arena allocation between the two pushes keeps the
|
|
;;;; first block from being grown in place.
|
|
(defn main [] i32
|
|
(let [a (arena-new 4096)
|
|
v (vec-new i32 a)]
|
|
(dotimes [i 4] (push v (+ i 1)))
|
|
(let [s (slice v)
|
|
other (vec-new i32 a)]
|
|
(push other 0)
|
|
(push v 5)
|
|
(println (at s 0))
|
|
(println (at v 0))))
|
|
0)
|