Skip to content

Ownership: validate-ownership sees leaks (Reset state); drop exactly once for skipped for-patterns, comprehension Err carriers, generator locals, and &T fields of Drop types (#1384 #1488 #1490 #1504 #1548 #1492) - #1718

Merged
ehartford merged 3 commits into
mainfrom
drop-cluster
Sep 26, 2026

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Ownership/drop-scheduling change — alone in its battery with :drop-audit and :move-audit. Draft until posted.

Eric Hartford added 2 commits September 26, 2026 03:48
…nd an owned local still Init at a return is a leak (#1384, #1488)

The blank `x = const zst(T)` re-initialized a place in the drop-state
domain, so every moved-out local read as Init at its return and no leak
could be seen; and nothing looked at returns at all. Reset — blanked after
a move or drop, owning nothing — joins as a guarded drop beside Init, as
MaybeMoved beside a move, as garbage beside untouched memory; a move of it
is a use after move. At every return, a local some `drop` targets (owned
storage the lowering scheduled a drop for) that is still Init with no
sub-place moved or blanked is refused as a leak; a generator's next body,
whose locals live in its state across a yield, is exempt. The compiler
tree validates clean; the #1490/#1504/#1548 repros are caught or fixed.
…on's Err carrier, a generator's locals at exhaustion, and a &Db field (#1490, #1504, #1548, #1492)

- #1490: a refutable `for PATTERN in …` over consuming iteration skipped
  elements without dropping them; the skip edge now drops an owned element
  (bind_for_element_or_skip mirrors the comprehension path; the two
  payload-binding callers own their item).
- #1504: the for-comprehension desugars its fail arm to `___fail @ _`; the
  @-binding moved the carrier into the outer local and the wildcard under
  it moved the same subject into a discard temp (A7) — two owners. The
  outer binding owns the value; a wildcard inner pattern binds and discards
  nothing.
- #1548: lower_generator_next_body restores state fields into locals and,
  at exhaustion, the source body's scope exit dropped them while the state
  kept the same bytes for its own drop glue. The exhaustion rewrite blanks
  the state fields to the reset sentinel after those drops.
- #1492: get_type_name names a reference's pointee, so type_has_drop_impl
  called `&Db` Drop and a `mut self` receiver's `&Db` field was moved and
  blanked (a null parent on the next read). A reference or raw pointer
  never has a Drop impl.

Each pinned under --debug-alloc (leak count=0) and --validate-all.
@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven battery on 13550c6: build, :fixpoint, :drop-audit, :move-audit green; :test rc=1 on two internals fixtures (mir_vacated_payload_drop_test, mir_move_of_moved_place_test): they initialize a fresh local with the zero-sized blank, which the new Reset transfer read as a reset. Fix in progress (a blank into untouched memory initializes; Reset joins with Init as Init). Stays draft.

…ve one; the validator's fixtures initialize with a value, not the reset blank

Reset joined with Init as Maybe, so a payload moved out and reset on one
arm read as vacated when the enum was dropped at the join, and a local
reset on one arm and live on the other was refused a move there. The blank
frees nothing on its path: the join drops and moves as the live path does.

mir_vacated_payload_drop_test and mir_move_of_moved_place_test built their
fixtures' initial value from the zero-sized blank, which is the reset
sentinel, not a value (every lowering site blanks a place it has moved
from, some after its StorageDead); they now initialize with an empty
aggregate. The tree's own validate-all stays clean.
@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven battery green on 94b9f12 (alone, with :drop-audit and :move-audit; host darwin-aarch64, seed per seed.lock):

drops build  rc=0
drops build :fixpoint rc=0
drops build :drop-audit rc=0
drops build :move-audit rc=0
drops build :test rc=0
drops build :test-green rc=0
drops build :last-green rc=0
drops build :user-programs-safe rc=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant