You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MIR validator negative coverage: validate_mir_body and use-after-kill have no malformed-MIR cases #989
Restated 2026-10-25.src/MirValidationTests.w now constructs malformed MIR for the typed and ownership validators. What is left: negative cases for validate_mir_body (structural checks) and validate_use_after_kill_body.
Original report
Classification
Testability gap, medium-low (audit finding VALID-001). The validators' rejection logic is real (verified by reading); nothing exercises it with invalid input.
Source chain
validate_mir_body checks locals-vector skew/return-local presence, module level checks duplicate fn_sym bodies + index-map agreement (src/Mir.w:2765-2800), validate_use_after_kill_body implements kill-on-zero-fill / revive-on-write / linear-reach gating (:2657-2704, plus the #927 postmortem proving it bites). But coverage is positive-only (--validate-* snapshot tests on valid programs, e.g. test/phase/validate_ownership_basic.w). Negative testing is structurally blocked from outside the compiler package: MirBody/MirModule non-pub (:393,490 — contrast pub type InternPool), validate_all_mir_module/validate_mir_body/validate_ownership_* non-pub free fns, and the one pub validator takes the non-pub body type.
Precedent
The codebase already solved this exact problem: Arena/Ids/InternPool re-homed as compiler.foundation.* + hostile-input unit tests in test/internals/*_test.w (e.g. arena_id_invalid negative controls). MIR validators never got it.
Repair boundary
Re-home or re-export the validator entry points and add hostile-body units: blank-then-read, duplicate fn_sym bodies, locals-vector skew, out-of-range terminator refs (the last also covers the trigger class of #982's stub-label finding).
Review: reproduced at the reported revision; partially addressed on main since 2026-09-10
Verdict. At 450733e the claim holds in full: no test fed malformed MIR to any validator, and the types and entry points needed to do so from outside the compiler package were private. One week after filing, commits ae79a08 through 62b7906 (2026-09-10) added src/MirValidationTests.w, an in-package module that constructs hostile bodies directly and asserts rejection verdicts, driven from test/internals/mir_uninitialized_drop_test.w. That closes the "structurally blocked" half by a different route than the report proposed (test code lives inside the package instead of re-homing the validators), and it gives the ownership validator real negative coverage. The other validators named in the report still have none, and the out-of-range terminator class has no validator to test at all (confirmed while reviewing #982 and #984).
Tested revision and compiler
item
value
reported revision
450733e: git show 450733e5:src/MirValidationTests.w fails (file absent)
HEAD
5809ac1 (2026-09-14); source read, no execution needed for this claim
platform
macOS Darwin 25.6.0, arm64
What exists on HEAD
src/MirValidationTests.w (94 lines, use MirCore) builds bodies with MirBody.init_for_fn / new_block / push_stmt / set_terminator and asserts on validate_ownership_body and validate_ownership_mir_module:
hostile case
assertion
drop of a never-initialised local, through Drop and DROP_AND_GOTO
.contains("never initialized it (Uninit)")
StorageDead parameter then drop
same rejection
drop of a non-global uninitialised local vs a marked global proxy
rejected vs == ""
zero-storage StorageLive then drop
== ""
two bodies both failing in one module
verdict names fn sym1 and fn sym2
plus mir_drop_plan_action sentinel checks. The file's header comment states the report's thesis verbatim: "testing only corrected source lowering would leave the validator's original false-green result untested."
What is still missing (the report's list against HEAD)
no validator exists (validate_mir_body checks array lengths only), so nothing to test yet
Visibility is unchanged (src/MirCore.w:393type MirBody, :493type MirModule, validators non-pub except validate_use_after_kill), which is fine given the in-package test module pattern, but means every future hostile test must be added inside src/.
Related PRs / commits
ae79a08, 329a63d, 13ba02e, 62b7906, f97bacf, 0378d52 (all 2026-09-10): introduced and iterated the test module while fixing ownership-validator false greens (global proxies, zero storage, deferred temporaries, parameter entry storage). These address this issue for the ownership validator.
Record in docs/deep-debugging-tools.md that hostile-MIR tests live in src/MirValidationTests.w and are run by test/internals/mir_uninitialized_drop_test.w, so the next validator author finds the pattern.
Untested
I did not execute the internals lane; the assertions were read, not run. Whether the lane runs in :test on every platform was not checked.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced, narrower than reported. Correction to an earlier triage note: there is a malformed-MIR harness. src/MirValidationTests.w builds invalid MIR directly (34 mir_test_* cases, run from test/internals/) and exercises validate_typed_mir_body and validate_ownership_body. What is still uncovered: no case reaches the rejection paths of validate_mir_body (locals-vector skew, return-local presence, duplicate bodies) or validate_use_after_kill_body; the one validate_all_mir_module case tests only a failed-lowering body.
post-release: test coverage for two validators, the harness to extend already exists.
changed the title [-]MIR validator rejection paths have no negative coverage (hostile-MIR testing structurally blocked)[/-][+]MIR validator negative coverage: validate_mir_body and use-after-kill have no malformed-MIR cases[/+]on Oct 25, 2026
Fixed in #3255 (6a905fd): test/internals/mir_structural_validator_test.w builds malformed MIR by hand and requires validate_mir_body and the use-after-kill validator to refuse each case (bad switch default, a use after a kill, a field through a reference).
Activity
ehartford commentedon Sep 16, 2026
Review: reproduced at the reported revision; partially addressed on main since 2026-09-10
Verdict. At 450733e the claim holds in full: no test fed malformed MIR to any validator, and the types and entry points needed to do so from outside the compiler package were private. One week after filing, commits ae79a08 through 62b7906 (2026-09-10) added
src/MirValidationTests.w, an in-package module that constructs hostile bodies directly and asserts rejection verdicts, driven fromtest/internals/mir_uninitialized_drop_test.w. That closes the "structurally blocked" half by a different route than the report proposed (test code lives inside the package instead of re-homing the validators), and it gives the ownership validator real negative coverage. The other validators named in the report still have none, and the out-of-range terminator class has no validator to test at all (confirmed while reviewing #982 and #984).Tested revision and compiler
git show 450733e5:src/MirValidationTests.wfails (file absent)What exists on HEAD
src/MirValidationTests.w(94 lines,use MirCore) builds bodies withMirBody.init_for_fn/new_block/push_stmt/set_terminatorand asserts onvalidate_ownership_bodyandvalidate_ownership_mir_module:DropandDROP_AND_GOTO.contains("never initialized it (Uninit)")StorageDeadparameter then drop== ""StorageLivethen drop== ""fn sym1andfn sym2plus
mir_drop_plan_actionsentinel checks. The file's header comment states the report's thesis verbatim: "testing only corrected source lowering would leave the validator's original false-green result untested."What is still missing (the report's list against HEAD)
validate_ownership_bodyvalidate_use_after_kill_body(kill-on-zero-fill, revive-on-write, linear-reach)validate_mir_bodystructural checks (locals-vector skew, term-array length mismatch)fn_symbodies / index-map agreementvalidate_typed_mir_bodyvalidate_mir_bodychecks array lengths only), so nothing to test yetVisibility is unchanged (
src/MirCore.w:393type MirBody,:493type MirModule, validators non-pubexceptvalidate_use_after_kill), which is fine given the in-package test module pattern, but means every future hostile test must be added insidesrc/.Related PRs / commits
Would I champion the remainder? Yes.
Acceptance criteria:
MirValidationTests.wwith hostile bodies forvalidate_use_after_kill_body(blank-then-read, revive-on-write),validate_mir_body(locals-vector skew), the module-level duplicate-fn_symcheck, andvalidate_typed_mir_body(argument type/count mismatch, which await in fn-param defaults checks green but is invisible to the suspend artifact #986 and Impl method arity is not checked against the trait (types are, D140): an extra parameter fails late #988 showed slipping through).goto,switchtarget,callnext block, and theswitchdefault sentinel per Switch-default d2==0 means abort() in C but bb0 in LLVM (unenforced convention) #984's ruling).docs/deep-debugging-tools.mdthat hostile-MIR tests live insrc/MirValidationTests.wand are run bytest/internals/mir_uninitialized_drop_test.w, so the next validator author finds the pattern.Untested
I did not execute the internals lane; the assertions were read, not run. Whether the lane runs in
:teston every platform was not checked.ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced, narrower than reported. Correction to an earlier triage note: there is a malformed-MIR harness.src/MirValidationTests.wbuilds invalid MIR directly (34mir_test_*cases, run fromtest/internals/) and exercisesvalidate_typed_mir_bodyandvalidate_ownership_body. What is still uncovered: no case reaches the rejection paths ofvalidate_mir_body(locals-vector skew, return-local presence, duplicate bodies) orvalidate_use_after_kill_body; the onevalidate_all_mir_modulecase tests only a failed-lowering body.post-release: test coverage for two validators, the harness to extend already exists.
[-]MIR validator rejection paths have no negative coverage (hostile-MIR testing structurally blocked)[/-][+]MIR validator negative coverage: validate_mir_body and use-after-kill have no malformed-MIR cases[/+]Issues batch F: #1071 #984 #989 #2269 (#3255)
ehartford commentedon Nov 11, 2026
Fixed in #3255 (6a905fd): test/internals/mir_structural_validator_test.w builds malformed MIR by hand and requires validate_mir_body and the use-after-kill validator to refuse each case (bad switch default, a use after a kill, a field through a reference).