Skip to content

validate-ownership accepts a drop of a temp that is Uninit on one incoming path (Maybe conflates maybe-moved with maybe-uninit) #1559

Closed

Description

@ehartford

Found while implementing D61 (#1480). A synthesized enum formatter registered its per-arm formatted-payload temps in one statement frame and dropped them at the join; on the arm that never initialized the temp the drop freed stack garbage (with run of test/behavior/derive_enum_debug_clone.w: invalid free addr=... panic: invalid free: pointer is not an allocated payload start).

--validate-all said ok and --dump-drop-plan classified the drop as

bb12.stmt3 place=_7 ty=ty16 state_before=Maybe action=conditional text="drop(_7) @ drop#3 scope-exit _7;"

i.e. Uninit on one edge, Init on the other, joined to Maybe, and Maybe is treated as a guarded (reset-on-move) drop. A local that was never assigned on a path is not null-blanked — LLVM allocas are not zero-initialized — so the guard does not protect it. #1111 made a pure Uninit drop invalid; the Uninit-on-some-path case still passes. This is the lattice gap #1414 describes (maybe-moved vs maybe-uninit need to stay distinct).

The lowering bug is fixed in the D61 PR (each arm gets its own frame); the validator gap remains.

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