Watch: save a page's old bytes before any guard is opened #2239
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!2239
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2239/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?
@denkencar-sketch on GitHub · 2026-11-25 08:31 UTC · original
denkencar-sketch:fix/watch-save-before-open→main· +19 −7 · 1 files · 1 commits · merged 2026-11-25 21:55 UTCSummary
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.
@MamaLeVrai on GitHub · 2026-11-25 09:13 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 12:44 UTC · original
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