Repository navigation
Description
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
Sema owns cast acceptance and the wildcard let; MirLower reads Sema's…
Sema owns cast acceptance and the wildcard let; MirLower reads Sema's…
Sema owns cast acceptance and the wildcard let; MirLower reads Sema's…
Spec v7.19: an implicit fill observes and never consumes; std.context…
Sema owns cast acceptance and the wildcard let; MirLower reads Sema's…
#2049 WIP: ownership-validator causes in MirLower/Sema/MirCore (impli…
#2049 WIP: compiled-Regex =~ condition drops its Option; fixtures
#2049 WIP: comparisons read operands (copy, not move); validator test…
#2049 WIP: lower_comparison_operand
#2049 WIP: D87 implicit fills observe (non-Copy implicit T not filled…
#2049 WIP: implicit_param_fillable is mut
#2049 WIP: TempArena link helper is an unsafe fn
#2011's pre-existing validate-all reds, each at its root (#2011)
Sema owns cast acceptance and the wildcard let; MirLower reads Sema's…
#2049 WIP: ownership-validator causes in MirLower/Sema/MirCore (impli…
4 remaining items
#2049 WIP: implicit_param_fillable is mut
#2049 WIP: TempArena link helper is an unsafe fn
#2049/#1036 WIP: regex literal code is owned by a module global the e…
#2011's pre-existing validate-all reds, each at its root (#2011)
#2011's pre-existing validate-all reds, each at its root (#2011)
One implementation of the fixes this branch shared with #2049
Sema owns cast acceptance and the wildcard let; MirLower reads Sema's…
#2049: synthesized bodies get their own by-address local maps; regex …
#2049: =~ observes a compiled Regex (it moved the regex into a tempor…
#2011's pre-existing validate-all reds, each at its root (#2011)
One implementation of the fixes this branch shared with #2049
#2049: ownership-validator verdicts in 24 behavior programs fixed at …
Cancellation: indirect callees that may suspend get the cancelled-ret…
#2043: name-callee calls lower by Sema's resolved kind; sym_is_generi…