Skip to content

Ownership MIR validator reports violations in 24 passing behavior programs (blocks strict validators, #2043) #2049

Closed

Description

@ehartford

Found during #2043 (D65 phase 5, "validators strict"). The ownership MIR validator (validate_ownership_mir_module, what --validate-ownership and audit:all run) was turned on for every build on wave-d65c. It reports a violation in 24 behavior programs that build and pass today, and in rt/cimport_stubs.w. The rt/cimport_stubs.w one was a real miscompile, now fixed on wave-d65c: let _ = x moved x against Sema's D5/P1 rule, and let _ = h; h.len() returned 0. Running the validator in the build is reverted until these are fixed. Each one is either a MIR ownership bug, as the cimport one was, or a validator false positive; either way it needs its exact line (debug-allocator route).

Findings (stage1 of wave-d65c, first verdict per program):

  • test/behavior/async_tuple_await.w — fn sym13440(main) bb12: owned local _3 is still Init at return — no path drops or moves it (a leak)
  • test/behavior/behav_1974_eliminator_owned_at_ref_param.w — fn sym13444(main) stmt106 span=0: drop of _78 after a path reaching it moved it out and before its reset (MaybeMoved): this frees the value its new owner holds (§2.5.1)
  • test/behavior/behav_async_tuple_await.w — fn sym13440(main) bb12: owned local _3 is still Init at return — no path drops or moves it (a leak)
  • test/behavior/behav_bzip2_facade_roundtrip.w — fn sym13442(main) bb5: owned local _12 is still Init at return — no path drops or moves it (a leak)
  • test/behavior/behav_const_consumed_twice_materializes.w — fn sym13447(main) bb8: move of _2, which a path reaching it already moved out (Reset) and nothing re-initialized: two owners free one value (§2.5.1)
  • test/behavior/behav_cstr_from_ptr_to_owned.w — fn sym13439(main) stmt83 span=0: drop of _76 after a path reaching it moved it out and before its reset (Moved): this frees the value its new owner holds (§2.5.1)
  • test/behavior/behav_implicit_autoref.w — fn sym13443(combined) bb0: copy of _2 into parameter 1 of fn sym13440(by_value), which takes ownership of it, while this body drops _2 too: two owners free one value (§2.5.1)
  • test/behavior/behav_implicit_method_call.w — fn sym13444(main) bb0: copy of _3 into parameter 1 of fn sym13442(Scale.apply), which takes ownership of it, while this body drops _3 too: two owners free one value (§2.5.1)
  • test/behavior/behav_implicit_params.w — fn sym13442(test_automatic_resolution) bb0: copy of _1 into parameter 1 of fn sym13440(compute), which takes ownership of it, while this body drops _1 too: two owners free one value (§2.5.1)
  • test/behavior/behav_let_else_break_exits_loop.w — fn sym1625(header) stmt8 span=0: drop of _7 reaches a path that never initialized it (Uninit)
  • test/behavior/behav_record_copy.w — fn sym13442(test_record_update) bb5: owned local _1 is still Init at return — no path drops or moves it (a leak)
  • test/behavior/behav_record_update_large_struct.w — fn sym249(set) bb1: owned local _1 is still Init at return — no path drops or moves it (a leak)
  • test/behavior/behav_record_update.w — fn sym13444(test_basic_update) bb8: owned local _1 is still Init at return — no path drops or moves it (a leak)
  • test/behavior/behav_regex_capture_fstring.w — fn sym13438(test_regex_captures_inside_fstring) stmt25 span=0: drop of _13 reaches a path where it holds no value — written on one path, never written, dead or already dropped on another (Maybe); only a reset blank is safe to drop (§2.5.1)
  • test/behavior/behav_regex_language_semantics.w — fn sym13438(test_global_match_operator_progresses) stmt38 span=0: reset of _5 on a path where it was never moved: the value it holds is lost (§2.5.1)
  • test/behavior/behav_result.w — fn sym13451(try_divide) stmt11 span=0: reset of _5 on a path where it was never moved: the value it holds is lost (§2.5.1)
  • test/behavior/behav_std_context.w — fn sym13444(main) bb1: copy of _3 into parameter 0 of fn sym13439(traced), which takes ownership of it, while this body drops _3 too: two owners free one value (§2.5.1)
  • test/behavior/behav_task_join_cleanup_consumes_handle.w — fn sym13440(main) bb5: owned local _1 is still Init at return — no path drops or moves it (a leak)
  • test/behavior/behav_unwrap_or_large_str_payload.w — fn sym13448(main) stmt58 span=0: drop of _34 after a path reaching it moved it out and before its reset (MaybeMoved): this frees the value its new owner holds (§2.5.1)
  • test/behavior/behav_zlib_facade_roundtrip.w — fn sym13441(main) bb5: owned local _12 is still Init at return — no path drops or moves it (a leak)
  • test/behavior/errdefer_basic.w — fn sym13441(test_errdefer_on_error) stmt12 span=0: reset of _3 on a path where it was never moved: the value it holds is lost (§2.5.1)
  • test/behavior/errdefer_ordering.w — fn sym13441(test_ordering) stmt9 span=0: reset of _3 on a path where it was never moved: the value it holds is lost (§2.5.1)
  • test/behavior/errdefer_question_mark.w — fn sym13443(multi_step) stmt9 span=0: reset of _3 on a path where it was never moved: the value it holds is lost (§2.5.1)
  • test/behavior/issue51_semantic_compare_dispatch.w — fn sym13447(entry_eq) stmt4 span=0: drop of _2 after a path reaching it moved it out and before its reset (Moved): this frees the value its new owner holds (§2.5.1)

Repro: add validate_ownership_mir_module(mir_mod) after validate_typed_mir_module in Compilation.run_mir_lower, or run with check <file> --validate-ownership.

Activity

  1. added 15 commits that reference this issue on Oct 3, 2026
  2. 4 remaining items

  3. added 11 commits that reference this issue on Oct 3, 2026
  4. added 3 commits that reference this issue on Oct 4, 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