Repository navigation
Conversation
`guard_aliases` guarded the other mappings of a taken page and ignored what `protect` returned. While a write the guards do not see is under way through one of those mappings (`watch::writing`, a kernel read or a DirectStorage write), `protect` leaves the page out — it stays open and busy. The taken page was still removed from the changed pages and its saved bytes dropped (`Changed::taken`), although writes through the busy mapping would not mark it until `Writing::drop`; a marked copy-back then found it changed with nothing saved and kept the title's bytes, dropping the shaders' writes (Marvisak#2454). `guard_aliases` now returns the taken pages one of whose mappings was not guarded, and `Tracked::take` and `Tracked::taken` leave those out: they stay changed and keep what they saved until every mapping of them can be guarded. `title_memory_aliased` does the same when the new mapping of a guarded page cannot be guarded: it marks the page changed without saving, so the tracked mappings pick the writes up and armed bytes are kept. Tests: `a_page_whose_other_mapping_is_busy_is_not_taken` (a marked copy-back across a busy mapping: before, the page was taken and its saved bytes went; now it stays changed and keeps them) and `linking_an_unguardable_mapping_keeps_the_tracked_page_changed` (the new mapping is busier than the guard: before, the tracked page stayed current). Both fail without the change. Lib suite: 199 passed, 1 ignored, plus the known placed-view failure on a runtime without `ID3D12Device10` (Marvisak#1999); clippy `-D warnings` clean.
c316e0d to
1d5e3b1
Compare
|
Independent verification (software WARP only)
Commands and results
Review: Looks correct. Review and verification by Claude Code (Claude Sonnet 5.5), AI-assisted; no game files, dumps, shader names or hashes involved. |
fyernald
left a comment
There was a problem hiding this comment.
Tested on real hardware: RTX 3080 (617.42), Windows 10 (19045), main 67e8ae1. cargo test -p victory-gpu --lib --locked -- --test-threads=1 gives 194 passed, 3 failed. Both new tests pass. The 3 failures also fail on main here: the heap cap (FIND-9) and the Windows 10 castable test (#1999).
This is the same fix as #2455 for #2454: guard_aliases returns the pages with an unguardable mapping, and take/taken leave those changed. The one real difference is in title_memory_aliased, and I think this PR has it right. Once a busy mapping is linked, the unseen write may already have landed through it, so changed(..., save = true) (#2455) could save post-write bytes as what the page held before. save = false keeps whatever was saved earlier and saves nothing new. This test also cleans up the global guard and alias state before freeing its pools, which matters given the parallel-run flakes in this crate. Only one of #2455 and #2561 should land.
|
Automated triage for the maintainers. Proposed close: duplicate of #2455. Both PRs fix issue #2454 with the same code change in CI: the This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. Generated by Claude Code |
|
Superseded, closing: current main already carries this fix (the busier-alias case is handled by Thanks to everyone who reviewed it while it was open — the diagnosis held, upstream just landed it in a different shape. |
Fixes #2454.
The failure
guard_aliasesguarded the other mappings of a taken page and ignored whatprotectreturned. While a write the guards do not see is under way through one of those mappings (watch::writing: a kernel read or a DirectStorage write),protectleaves it out — it stays open and busy. The taken page was still removed from the changed pages and its saved bytes dropped (Changed::taken), although writes through the busy mapping would not mark it untilWriting::drop. A marked copy-back then found it changed with nothing saved and kept the title's bytes, dropping the shaders' writes.title_memory_aliasedignored the result the same way for the new mapping of a guarded page.protectalready documents the rule this restores: "a page that is mapped but cannot be guarded is left out (it stays changed)", andwatch.rssays "taking a page guards every address showing it".What the change does
guard_aliasesreturns the taken pages one of whose mappings was not guarded.Tracked::takeandTracked::takenleave those out: they stay changed and keep what they saved until every mapping of them can be guarded. A page is retaken on the next refresh/copy-back once the mapping is out ofbusy.title_memory_aliased, when the new mapping of a guarded page cannot be guarded, marks the page changed without saving (changed(..., false), which follows the alias links), so the tracked mappings pick the writes up and armed bytes are kept.A blocked page is copied as usual (the copy is correct for what the title wrote so far); only its "taken" state is kept.
Verification
a_page_whose_other_mapping_is_busy_is_not_taken: a tracked page taken and armed, linked tob, then a kernel write throughb; a refresh takes the page meanwhile. Before: the page was taken,Changed::takendropped its saved bytes, andchangedbecame false. Now: it stays changed and keeps what it saved; after the write ends,bcan be guarded and the page is taken. Both assertions fail on the old code.linking_an_unguardable_mapping_keeps_the_tracked_page_changed:bis busy when the runtime links it to the tracked pagea. Before:astayed current and writes throughbwere missed; now it stays changed. Fails without the change.cargo test -p victory-gpu --features diagnostics --libon Windows 10 19045 / RX 7800 XT: 199 passed, 1 ignored, plus the known placed-view failure on a runtime withoutID3D12Device10(#1999, identical onmain); clippy-D warningsclean. Three consecutive runs, same result.One thing I left alone: a page guarded only through an alias (no tracker holds it) is not opened when the runtime unmaps it, so the guard set can name freed memory. That is a different change (
title_memory_remapped/openof unheld pages), and the issue is about the take.