Skip to content

validate-ownership is blind to leaks: an owned local still Init at a return passes validate-all (#1365 leak was 'ok') #1384

Closed

Description

@ehartford

A tool that stayed silent (CLAUDE.md): on #1365 repro 1 the failing let-else path returned with the materialized subject _3: Result[i32, str] still Init and no drop, and --validate-all said validate-all: ok. validate_ownership_body (src/MirCore.w) only rejects drops that reach Uninit/MaybeGarbage places; nothing checks the converse — an owned (type_needs_drop) local that is definitely Init at a TK_RETURN (or leaves its scope on a break/continue edge) without a drop, move, or reset.

Seed MIR of repro 1 (fn refutable), fail block:

bb3: {
    _0 = const -1ty3;
    _2 = const zst(ty425);
    return;            // _3 = Init (drop-state dump), never dropped
}

and --dump-drop-state shows bb3 out: ... _3=Init. The debug allocator caught it (leak count=1); the validator did not.

What a check has to handle so it is not noise:

  • reset-on-move blanks (_2 = const zst) leave the place Init in the drop-state lattice although it owns nothing — the lattice needs a Blanked/zeroed state, or the check must treat a zst/zero assign as a move;
  • the return local _0, share-place (IndirectPlace) parameters, and view locals own nothing;
  • partially moved aggregates (moved-field exclusions).

Filed from #1365 rather than landed with it: #1365 is a drop-scheduling fix that must sit alone in its batch, and PR #1353 is reworking the drop-state pass storage this check would extend. The #1365 PR adds the let-else family to tools/drop_audit.w (40 cells) so that region is no longer uncovered.

Activity

  1. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Fixed by #1718: validate-ownership has a leak rule (an owned local some drop targets, still Init at a return with no sub-place moved or reset, is reported). Verified on main 3ccb998: #1365's shape is now reported by check --validate-all. That report exposed a let-else lowering defect, tracked as #1750.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions