roadmap BUILT

310. The Miri leak check stays on, and the test pool it caught cannot leak again

.github/workflows/undefined-behavior-check.yml had never once succeeded. Five scheduled runs since 2026-08-11, all red, with script/cadence-check (milestone 238) reporting it DEAD. The cause was not undefined behavior:

error: memory leaked: alloc78416 (Rust heap, size: 4096, align: 4096), allocated here:
   --> crates/page_tables/src/domain.rs:425:26
error: aborting due to 5 previous errors
error: test failed, to rerun pass `-p page_tables --lib`

crates/page_tables's domain tests back synthetic physical addresses with real zeroed host frames, so the page-table walker has memory to walk. Those frames were never freed. cargo test does not care, because the process exits; Miri checks for leaks by default and does.

The measurement

script/undefined-behavior-check, the full sampled workspace, on patagonia:

script/undefined-behavior-check  5429.38s user  18.55s system  47% cpu  3:09:41.64 total
[exited with code 0]

Three hours nine minutes, and green. No failure appeared behind the leak, which is worth saying plainly because the workflow's header warns to expect one. cargo miri test stops at the first failure. The last time this job was taken apart a three-week red turned out to have three causes. This time the first fix was the only fix.

And it passes in CI, which is the measurement that settles it. workflow_dispatch on this branch, run 35256118545 on ubuntu-24.04-arm: success in 2:58:13, the workflow's first green since it was written. The two figures agreeing within eleven minutes across two very different machines is worth having, because it means three hours is the job's cost rather than this laptop's.

The 47% CPU is the load-bearing part of the local line: most of this is one interpreter thread, so it is wall clock that more cores will not buy back. The old 141-minute figure was a red run that died partway and never measured a finishing one, which is the header's point that a failing check is also not measuring.

The part worth reading: the guard was not missing

The obvious story is "a fixture nobody taught to free". It is wrong, and the correct story is the reason this milestone changed a shape instead of adding a line.

PoolGuard was added on 2026-08-03 (d0f74db9, "paging: the test harnesses free what they allocate") for exactly this leak, with a Drop that drains the thread-local map and deallocates every frame. It worked. What it required was that each test remember to write let _pool = PoolGuard; as its first line.

a_multi_page_grant_maps_its_whole_pages_and_not_the_partial_tail, written afterwards, did not. One test out of four, five frames, five weeks of red.

That is AGENTS.md's ladder, rung four, failing the way rung four fails. The whole list of sites confirms it: page_frame_at was the only function allocating, page_frame the only other caller of it, and the thread-local PHYS had no third writer anywhere in the crate. Nothing was subtle. Binding the missing line would have restored the identical defect for the next test author, and the next author is exactly who this file says cannot be relied on to remember.

So the fix goes up the ladder to rung one, make the wrong state unrepresentable. frame and frame_at are now methods on FramePool, the free functions are gone. A test that allocates a frame without holding a pool does not compile. The receiver is otherwise unused, and that is the point of it.

Three smaller things came with it, each closing a way the fix itself could be wrong:

The two options that were refused, and why

calef ruled on 2026-09-17. Recording the refusals rather than only the choice, per §75:

-Zmiri-ignore-leaks, workspace-wide. Refused. It trades a permanent reduction in what Miri checks for a one-time cost, which is the wrong direction on a check that had already gone five weeks without anybody noticing it was checking nothing. This project's no_std crates are host-testable on purpose, and a future host test of an allocator is precisely the thing leak checking would earn its keep on; turning it off now spends that in advance to save an afternoon.

A paging-scoped ignore. Refused. Narrower, and still an ignore, but it also does not exist: cargo xtask undefined-behavior-check runs one cargo miri test --workspace with a static exclusion list and MIRIFLAGS is a process-wide environment variable, so per-crate flags would need a mechanism built first. Paying for machinery whose purpose is to check less is the losing side of both arguments at once.

The honest cost of what was done instead: one afternoon, one crate, 60 lines changed in one test module, no production code touched, and no test covering less than it did. That comparison is why the decision was not close.

Freeing changed nothing about what the tests cover

Worth stating explicitly, because "make the leak go away" has a bad version where the frames stop being allocated and the walker stops walking real memory. Every test allocates exactly the frames it did before, at the same synthetic addresses, and asserts the same things. The only difference is that the allocations are reachable from a value that outlives them and frees them. All four domain tests and the crate's other thirty pass unchanged.

BUGS

Follow-on

Index row

.github/workflows/undefined-behavior-check.yml had never once succeeded, five scheduled runs red since 2026-08-11, and the cause was never undefined behavior: crates/page_tables's domain tests leaked five zeroed host frames, which cargo test ignores and Miri's default leak check does not. The interesting part is that the guard was not missing. PoolGuard had been added on 2026-08-03 for exactly this leak, and a test written afterwards simply did not bind one, which is AGENTS.md's rung four failing the way rung four fails. Binding the missing line would have restored the identical defect for the next author. So allocation moved onto the pool itself and a test that allocates a frame without holding one no longer compiles. calef refused both alternatives on 2026-09-17, -Zmiri-ignore-leaks globally and a paging-scoped ignore, on the ground that a permanent reduction in what Miri checks is the wrong trade for a one-time cost; the refusals and their reasons are in the block. Measured: three hours nine minutes, exit 0, full sampled workspace, with no second failure hiding behind the first, which supplies the honest cost figure the workflow's own header says is "not yet known", and confirmed green in CI at 2:58:13.