You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with analyze ... audit:all reports zero violations for a HashMap extraction
that creates two owners of the same string payload. The native allocator's
scribble mode makes the stale read deterministic.
At 69bf4e70, an ordinary run succeeds; WITH_DEBUG_ALLOC_SCRIBBLE=1 with run --debug-alloc repro.w fails. The equivalent values() case reads a freed
value; items() also frees map-owned strings. audit:all passes all three.
Instruction-level evidence from #1158: sema_clone_str_str_hashmap calls with_hashmap_keys_out, then its generated Vec drop frees the source map key
at helper +404 (0x1004ece58 in the diagnostic Darwin binary). That address is
reused for a trait HashMap allocation and later freed through the stale source
map key. Native address-trap backtraces prove the full lifetime. The extraction
intrinsics raw-copy non-Copy elements into an owning Vec without a clone or
view contract. The audit currently does not validate this intrinsic ownership
boundary.
Expected: ownership auditing must reject an intrinsic whose declared result
owns payloads that its implementation only borrows/shallow-copies, or record
and validate a correct independent-ownership/view contract. Spec §§3.8, 21.1
and the owning-map contract require valid ownership and origin preservation.
No workaround applied. The collection implementation fix is tracked with #1158; this issue records the silent validator required by AGENTS.md.
Three more places with the same shape, in case they're useful for the audit's coverage: SlotMapSlot.get(), VecSlot.get(), and Option[str].unwrap_or. Each returns an owning copy of a non-Copy element that shares the source's heap payload, and audit:all passes all three.
Checked with a source build of main at 69bf4e70 on Windows x86_64. Your repro above behaves as described there (plain run ok, scribble panics called unwrap on None, audit:all → violations=0), so the setup matches.
SlotMapSlot.get()
use std.collections.SlotMap
type Courier { name: str, n: i32 }
fn main:
var m: SlotMap[Courier] = SlotMap[Courier].new()
let src: &str = "bob"
let h = m.insert(Courier { name: src.clone(), n: 0 })
with m.slot(h) as mut s:
let c = s.get()
print(f"inside: {c.name}")
let noise = f"{m.len()}-noise"
print(f"after: name={m.get(h).unwrap().name} {noise}")
VecSlot.get() → set() (the get / modify / set pattern)
type Courier { name: str, n: i32 }
fn main:
var v: Vec[Courier] = Vec.new()
let src: &str = "bob"
v.push(Courier { name: src.clone(), n: 0 })
with v.slot(0) as mut s:
var c = s.get()
c.n += 1
s.set(c)
let noise = f"{v.len()}-noise"
print(f"after: name={v[0].name} n={v[0].n} {noise}")
Option[str].unwrap_or
fn lookup(names: &Vec[str], i: i64) -> Option[str]:
if i < names.len():
Some(names[i].clone())
else:
None
fn main:
var names: Vec[str] = Vec.new()
let src: &str = "player"
names.push(src.clone())
for i in 0..2:
let name = lookup(names, i)
let label: str = name.unwrap_or("?")
print(f" {label} <- typed str")
Results, identical pattern for all three:
run --debug-alloc
+ WITH_DEBUG_ALLOC_SCRIBBLE=1
analyze … audit:all
SlotMapSlot.get()
exit 0, name= prints stale bytes, leak count=0
exit 0, name=���, leak count=0
violations=0 ok
VecSlot.get()/set()
exit 0, name= prints stale bytes, leak count=0
exit 0, name=���, leak count=0
violations=0 ok
Option[str].unwrap_or
exit 0, correct output, leak count=0
exit 0, ������ <- typed str, leak count=0
violations=0 ok
Unlike the keys() case these don't panic under scribble; they just print freed memory and exit 0, so the only signal is wrong output. The replace-and-swap-back form (m.replace(h, …) instead of get()) stays correct under scribble, which may be a useful control.
Fixed by #2451 (main 809561f): slot/range/entry extraction refuses a non-Copy element in Sema, runs copy glue in codegen, and analyze audit:all fails on an extraction intrinsic whose element is not Copy (src/Analysis.w). Pins: test/compile_errors/err_slot_get_non_copy.w, test/behavior/behav_slot_get_copy_glue.w.
Activity
joshhickson commentedon Sep 17, 2026
Three more places with the same shape, in case they're useful for the audit's coverage:
SlotMapSlot.get(),VecSlot.get(), andOption[str].unwrap_or. Each returns an owning copy of a non-Copy element that shares the source's heap payload, andaudit:allpasses all three.Checked with a source build of
mainat69bf4e70on Windows x86_64. Your repro above behaves as described there (plain run ok, scribble panicscalled unwrap on None,audit:all→violations=0), so the setup matches.SlotMapSlot.get()VecSlot.get()→set()(the get / modify / set pattern)Option[str].unwrap_orResults, identical pattern for all three:
run --debug-alloc+ WITH_DEBUG_ALLOC_SCRIBBLE=1analyze … audit:allSlotMapSlot.get()name=prints stale bytes,leak count=0name=���,leak count=0violations=0 okVecSlot.get()/set()name=prints stale bytes,leak count=0name=���,leak count=0violations=0 okOption[str].unwrap_orleak count=0������ <- typed str,leak count=0violations=0 okUnlike the
keys()case these don't panic under scribble; they just print freed memory and exit 0, so the only signal is wrong output. Thereplace-and-swap-back form (m.replace(h, …)instead ofget()) stays correct under scribble, which may be a useful control.D22 compliant and its 66 fixtures promoted; D44 extraction copy glue (#…
ehartford commentedon Oct 18, 2026
Fixed by #2451 (main 809561f): slot/range/entry extraction refuses a non-Copy element in Sema, runs copy glue in codegen, and
analyze audit:allfails on an extraction intrinsic whose element is not Copy (src/Analysis.w). Pins: test/compile_errors/err_slot_get_non_copy.w, test/behavior/behav_slot_get_copy_glue.w.