GPU: a page whose alias cannot be guarded stays changed #2455
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2455
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2455/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@BastienRodz on GitHub · 2026-11-25 13:49 UTC · original
BastienRodz:gpu/busy-alias-stays-changed→main· +63 −9 · 1 files · 2 commits · merged 2026-11-25 21:57 UTCWhat's wrong
guard_aliasescalledprotecton a page's other mappings and dropped the result. While one mappingbof a physical page is busy with a write the guards do not see (watch::writing: kernel reads and DirectStorage writes into pool views),protectskips it.Tracked::take/takenthrough another mappingastill guardeda, removed it from the changed pages and dropped its saved bytes. Writes through the openbthen went unseen by the copy. When the write ended (Writing::drop, changed without saving), an armed page was left changed with nothing saved, andcopy_back_markeddropped the shaders' writes to it.title_memory_aliasedignoredprotect's result the same way.What the fix does
guard_aliasesreturns the pages that still have a mapping it could not guard. It returns an empty set at once when there are no aliases.takeandtakenleave those pages changed and keep their saved bytes, asprotect's own doc says for a page it cannot guard ("it stays changed"). They are taken at a later refresh, once every mapping can be guarded.title_memory_aliasedmarks the page changed (saving armed pages) when the new mapping of a guarded page cannot be guarded.Tests
New
watch::tests::a_busy_alias_leaves_the_page_changed_and_keeps_saved_bytes:a/bof one page,atracked and armed, a write under way throughb;takeandtakenthroughamust leave the page changed, a write throughbmust still be seen, and the saved bytes must survive the end of the write;Results:
main(940d32f) it fails attake must leave the page changed.watch::tests(7),shadow::tests(4) andvictory-hle'smodules::xmem::(10) pass (Wine 10, vkd3d-proton 3.1 on llvmpipe).Not tested
No title run, and no AMD/NVIDIA GPU. How often the title streams into a pool view while a copy of another mapping of the same pages is taken is not measured.
Fixes #2454
AI-assisted (Gemini 4 Neon found and wrote it, Claude Code reviewed and verified it). No game data used.
🤖 Generated with Claude Code
@oni-swr on GitHub · 2026-11-25 14:13 UTC · original
Independent WARP verification of #2455 at
4b92022(fixes #2454)Commands (Rust 1.98.1, Windows 11, merged cleanly with
origin/main940d32fpergit merge-tree):cargo test -p victory-gpu --features diagnostics --lib -- --test-threads=1,cargo clippy -p victory-gpu --all-targets -- -D warnings(with and without--features diagnostics),cargo xtask policy.a_busy_alias_leaves_the_page_changed_and_keeps_saved_bytes); clippy clean both ways; policy OK.watch.rsreverted toorigin/mainwith the new test kept -> the test FAILS (assertion in the test body), so it exercises the fix.guard_aliasesnow returns the pages with an unguardable alias, andtake/takenleave them changed and keep saved bytes;title_memory_aliasedmarks the page changed whenprotectcould not guard it.title_memory_remapped), #2377 (Saved/refreshed), and #2434/#2437 (shadow.rsonly) — no textual conflicts with this PR (git merge-treeclean against #2415 and #2377). #2415 and #2455 edit different functions; #2377 addsrefreshedover the same saved bytes this PR keeps, so they are complementary. I did not run the combined stack.AI-assisted verification by Claude Code (Claude Sonnet 5.5). Software-only: Microsoft Basic Render Driver (WARP, vendor 0x1414, forced by
VICTORY_D3D12_WARP=1+--features diagnostics;warp_adapter()refuses a non-software adapter), no physical GPU, no game files, dumps or hashes.@kotekompotek on GitHub · 2026-11-25 14:21 UTC · original
Verified on Windows 10 / GTX 1050 at
4b92022:a_busy_alias_leaves_the_page_changed_and_keeps_saved_bytespasses — twin views, real guard pages.The direction is right: an alias that cannot be guarded (a
Writingguard holds it open) must not lettake/takenmark the page clean — a write through the unguarded mapping would land unmarked and the copy-back would miss it. Keeping itchangedre-copies conservatively, andtitle_memory_aliasedmarkingchanged(save=true)when the new alias cannot be guarded is the same conservative move at registration. The test covers take, taken, saved-bytes survival, and the late-alias path.@BastienRodz on GitHub · 2026-11-25 15:49 UTC · original
Rebased onto main
da82e44.takeis now split intotake/take_split; thewhole.retain(..)for pages with an unguardable alias moved intotake_splitjust beforeprotect_noting. On the new main the test still fails without the fix (take must leave the page changed) and passes with it;watch::13/13,shadow::8/8.@Marvisak on GitHub · 2026-11-25 16:09 UTC · original · edited 2026-11-25 18:47 UTC
Automated triage for the maintainers.
Merge candidate. In
crates/victory-gpu/src/watch.rs,guard_aliasesnow returns the pages with another mapping thatprotectcould not guard (one kept open by aWriting).Tracked::take_splitandTracked::takenleave those pages changed and keep their saved bytes, asprotect's own doc says they should. Onmain,protect's result was ignored, so such a page was taken while writes through the busy mapping were still going unseen.title_memory_aliasednow marks the page changed when the new mapping cannot be guarded. The new testa_busy_alias_leaves_the_page_changed_and_keeps_saved_bytescoverstake,taken, survival of the saved bytes and the late-alias path, and independent runs report that it fails without the fix. CIcheckpasses.On your reply: the switch to
changed(.., save = false)intitle_memory_aliasedis right by my reading. The bytes of a mapping under a write may already hold that write. Without saved bytes,shadow.rscopy_back_markedkeeps the title's bytes (its documented shortcut) rather than taking the write for the GPU's. Two notes for the maintainer: #2561 fixes the same issue (#2454) the same way and was opened later, so only one of the two should land. Unlike #2561's tests, this test does not undo the alias link it makes withtitle_memory_aliased(c, &[a]), which could leave guard state behind for later tests that reuse the address. Unlinking at the end of the test would tidy that.Generated by Claude Code
@BastienRodz on GitHub · 2026-11-25 16:43 UTC · original
Thanks @fyernald, agreed. If the new mapping can't be guarded because a write the guards don't see is under way through it, its bytes may already hold that write, and saving them as the page's old bytes would get them taken for the GPU's at a marked copy-back.
a86706cmakestitle_memory_aliasedmark the page changed withsave = false, with a comment saying why.watch::tests13/13. That should make this and #2561 equivalent on that point.