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 drop of a Moved place (moved out, not yet reset) — a double free at runtime #1539
--validate-ownership accepts a drop of a place whose drop state is Moved (moved out, not yet reset). Drop flags are retired and codegen emits every drop statement, so that drop frees the value its new owner holds — a double free. --dump-drop-plan even labels it skip, and mir_elaborate_dead_drops (which would NOP such drops) has no caller.
Found on #1412's shape (stage1 of origin/main ba2d5d1):
gen fn words(count: i32) -> str:
var i = 0
while i < count:
let w = f"w{i}"
yield w
i += 1
fn main:
for s in words(3):
print(s)
run --debug-alloc: prints w0, then DOUBLE FREE … first_drop=drop#struct __drop_struct_16. The generator's next body contains
— _10 is Moved at the drop (the reset comes after it), and --validate-ownership prints ok. (The wrong place comes from lower_generator_next_body remapping a Drop's place id through the local map; fixed in the #1412 PR. The validator should have named it.)
Expected: the ownership validator rejects a drop whose place is Moved on every path reaching it: "drop of _10 after it was moved out and before its reset; this frees the value its new owner holds". Maybe (moved on some paths, reset there) stays legal.
Needs a corpus sweep with the check before landing (companion of #1487, the reset-of-Init check).
Activity
MIR: a yield drops its statement temporaries before suspending; the n…
MIR: a yield drops its statement temporaries before suspending; the n…
MIR, codegen: a closure handed to a scope's spawn is moved into the t…
validate-ownership: a drop of a place moved out and not yet reset is …
MIR: a carrier eliminator reads the mapper it calls — `map`'s Ok arm …
Ownership: D72 liveness byte, D73 assignment-as-read, validator leak/…