Watch: save a page's old bytes before any guard is opened #2237
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2239"
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?
Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T08:31:52Z.
Summary
changed_hereopens the guarded pages (VirtualProtectto read-write) and only then marks them and saves their bytes for armed trackers (Changed::save, "before the write lands").changedalso opens the faulting range before it handles the pages aliasing it. Once a page is open, a write by another thread lands without a fault, and asaveafter that keeps the new bytes as the page's old bytes.Shadow::copy_back_markedthen sees no difference between the copy andbeforeand overwrites the other thread's write in title memory.Change
changedmarks and saves the range and its aliases first (mark_changed), and opens them after (open_guarded). Nothing else changes: same marks, same saves, same pages opened, same return value.Testing
No new test. It is a window between two calls on two threads, which I could not hit deterministically. The existing tests pass (143 in
victory-gpu, three runs, and the full workspace), andcargo clippy --workspace --all-targets [--all-features] --locked -- -D warningsis clean. This is a reordering found by reading, so please read it with that in mind.Not tried: a run in the game.
modules::dstorage::tests::a_page_list_filled_after_its_request_startsfails now and then onmaintoo (5 of 20 runs ofcargo test -p victory-hle --lib); it is unrelated.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T08:42:34Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-gpu --lib watch::— 6 passed, 0 failedcargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean ordering fix saving a page's old bytes before any guard is opened in
watch.rs. Looks good.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:48:34Z.
Review: COMMENTED
Watch: a page's old bytes are saved before any guard is opened — reorders changed() so mark_changed runs for all pages/aliases before open_guarded, closing a race where a concurrent write would be kept as 'old bytes'. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Same cluster; the ordering fix is subtle and correct-looking.
Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-25T09:13:33Z.
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head
583c14d5intomain940d32fin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with--all-features: clean.cargo test --workspace --locked: 701 passed, 0 failed, 10 ignored, two runs (mainalone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T12:44:42Z.
Automated triage for the maintainers.
Merge candidate. In
changed(crates/victory-gpu/src/watch.rs), on a write fault to a range and its aliases,mainsaved and opened one page at a time. Once one page was open, another thread's write could land on an alias that had not been saved yet, and that alias's "old bytes" would then already contain the write. The PR splitschanged_hereintomark_changed(save and mark) andopen_guarded. It saves every page, the range and all its aliases, before opening any of them. The returnedguardedvalue is computed the same way as before.The reordering is right by my reading. There is no test, which is understandable for this race. CI
checkpasses, an RX 6950 XT run shows the full workspace green, and the branch merges cleanly.Generated by Claude Code