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
{{ message }}
Repository navigation
validate-ownership accepts a reset-on-move blank of a place that is still Init (a lost value) #1487
--validate-ownership accepts a reset-on-move blank (_N = const zst) of a place whose drop state is Init — a value no path moved is overwritten without a drop, so it is lost (leak) and every later read sees the blank.
Found on #1383's branch: with Sema's let-else rejection fixed, MIR for
fn vec_or_err(k: i32) -> Result[Vec[str], str]:
if k == 0: return Err("none".clone())
var v: Vec[str] = Vec.new()
v.push("a".clone())
v
fn consume(s: str) -> i32: s.len() as i32
fn h(k: i32) -> i32:
let keep = "keep".clone()
let Ok(v) = vec_or_err(k) else: return consume(keep) - 100
keep.len() as i32 + v.len() as i32
blanked keep on the matching path (the else branch's pending reset leaked into the let-else statement's flush; fixed in the #1383 PR). --trace-ownership h:_2 showed the fact:
yet --validate-ownership printed ok; the program printed -96 1 (not -96 5) and leaked keep's buffer.
Expected: the ownership validator rejects an Assign of a zero-sized/blank constant into a drop-bearing place (local or projected field) whose state before the statement is Init: "reset of _2 on a path where it was never moved; the value is lost". Moved, Maybe, Uninit and MaybeGarbage stay legal (a reset after a move, a conditional-move join, a zero-init).
Needs a sweep of the corpora with the new check before it lands (false-positive risk: any other lowering that writes a blank over a live value is itself this bug, but that has to be established case by case).
Activity
let-else: a move in the diverging else branch stays on that path — Se…
let-else: a move in the diverging else branch stays on that path — Se…
validate-ownership: a reset-on-move blank of a place no path moved (s…
Ownership: D72 liveness byte, D73 assignment-as-read, validator leak/…