Skip to content

validate-ownership passes a whole-enum drop after a variant payload moved out on one path (#1363 was validate-all: ok) #1394

Closed

Description

@ehartford

Tool silence found by #1363. For let t = read_file(p).unwrap_or(""), with check repro.w --validate-all and --validate-ownership both print ok over this MIR (origin/main 8c859a7):

bb2: _6 = move _4<as v0>.f0;            // payload moved out (success path)
bb4: drop(_4) @ drop#9 scope-exit _4;   // whole-enum drop glue frees it again

--dump-drop-plan even classifies it: bb4.stmt9 place=_4 ty=ty428 state_before=Maybe action=conditional, with _4<as v0>.f0=Maybe — yet codegen emits an unconditional __drop_struct_428(ptr %3) and nothing reports the conflict.

Two gaps:

  1. validate_ownership_body (src/MirCore.w) checks a Drop only for MaybeGarbage/Uninit. It should reject a whole-place Drop while a projected sub-place of that place is Moved/Maybe and was never re-initialized (reset-on-move, §2.5.1, re-inits it to Init) — the codegen has no drop flag for that case. The rule needs care: a whole-local conditional move sets the local and all children alike; the defect shape is a child more-moved than its parent chain.
  2. The underlying blind spot: consume_moved_operand (src/MirLower.w) only registers moves whose place is a pure field/tuple path (place_field_projection_count(place) > 0); a move out of an enum variant payload (PK_DOWNCAST then field) returns -1 and registers nothing — no reset-on-move, no moved-field mark. Every carrier eliminator therefore has to hand-roll its ownership (ok/err blank the payload; ?, ??, and since Result[str, E].unwrap_or returns a str with the payload's length and a bad data pointer (segfault / garbage) #1363 unwrap_or/unwrap_or_else/flatten retire the subject drop). A new eliminator that forgets is Result[str, E].unwrap_or returns a str with the payload's length and a bad data pointer (segfault / garbage) #1363 again, silently.

Also fixed in the #1363 PR: the debug allocator was silent on the str double free (with_str_free skipped a freed block as "not owned"); it now consults the ledger.

Activity

  1. added 19 commits that reference this issue on Sep 23, 2026
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