GPU watch: ignore zero-length writes and remaps on unaligned addresses (#2011) #2964
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2966"
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 Dukestar69 on 2026-11-26T01:44:25Z.
Summary
Short-circuit zero-length (
len == 0) ranges inwatch::writing,Drop for Writing, andwatch::title_memory_remappedso unaligned zero-byte writes and empty remaps do not mark pages dirty or unlink live aliases (credit to @tyr0nsur & @matheusfrta for identifying #2011).Fixes #2011.
Testing
unaligned_zero_length_writes_and_remaps_do_not_dirty_or_unlinkincrates/victory-gpu/src/watch.rs.cargo test -p victory-gpu watch::tests: 16/16 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:54:55Z.
Review: COMMENTED
Reviewed and verified against
main(63bcca43) on Windows 11 (RTX 5090 + WARP,VICTORY_D3D12_DEBUG=1) — clean fix for #2011 and ready to merge:len == 0inwriting(watch.rs:788-790),Writing::drop(self.first >= self.last,watch.rs:806-808), andtitle_memory_remapped(watch.rs:820-822) prevents unaligned zero-length ranges (at % PAGE != 0) from forming a 1-page[at / PAGE, at.div_ceil(PAGE))span and spuriously dirtying or unlinking aliases.pub(crate) fn retake(at: usize, len: usize)(watch.rs:849) does not yet haveif len == 0 { return; }— current callers inmemory.rspass non-zero ranges, so it's harmless today, just worth adding for API symmetry if desired.Local verification:
cargo test --locked -p victory-gpu --lib watch::: 16/16 passed on both RTX 5090 and WARP (VICTORY_D3D12_DEBUG=1), includingunaligned_zero_length_writes_and_remaps_do_not_dirty_or_unlinkcargo clippy --locked -p victory-gpu --tests -- -D warnings: 0 warningscargo xtask policy: 191 files okImported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T02:19:10Z.
Review: COMMENTED
Verified the bug: writing(a+1, 0) used to register guard range [page, page) — an empty span — but the drop then dirtied anyway and remapped would unlink the alias. Both early-outs are the right fix points, and the drop's first>=last guard is consistent. The test proves a real 1-byte write afterwards still dirty-tracks through the preserved alias link.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T05:29:03Z.
Automated triage for the maintainers.
This fixes #2011 in
crates/victory-gpu/src/watch.rs. With a zero length and an unaligned start,writingandtitle_memory_remappedround to a one-page range. That range marks a clean page and its alias dirty, or unlinks a live alias on an empty remap. The fix returns early forlen == 0, andDrop for Writingskips the empty range. A non-empty range always hasfirst < last, so real writes are unaffected. Zero lengths can happen in practice:writingtakes the title'sfreadsize times count, and the callers inshadow.rs/list.rspass computed lengths. The new test checks the empty write while the guard lives and after it drops, the empty remap, and that a real one-byte write still reaches the alias. No other open PR fixes #2011. CI: not run on this head yet.Verdict: merge candidate. Recommending a look, not approving.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T08:50:29Z.
Independent local verification of head
b6b6338on Windows 11, Rust 1.100.0/MSVC:cargo test --locked -p victory-gpu --lib watch::tests::unaligned_zero_length_writes_and_remaps_do_not_dirty_or_unlink— 1 passed, 0 failed.git diff --check origin/main HEAD— clean.CPU-only synthetic test; no game assets, GPU-specific hardware or DRM material used. AI-assisted (Hy4 flash).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.