GPU watch: ignore zero-length writes and remaps on unaligned addresses (#2011) #2966

Open
github-bot wants to merge 1 commit from github-bot/gh-2966 into main AGit
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 01:44 UTC · original
Dukestar69:fix/watch-empty-ranges → main · +34 −0 · 1 files · 1 commits · open

Summary

Short-circuit zero-length (len == 0) ranges in watch::writing, Drop for Writing, and watch::title_memory_remapped so 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

  • Added regression test unaligned_zero_length_writes_and_remaps_do_not_dirty_or_unlink in crates/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).

**@⁠Dukestar69** on GitHub · 2026-11-26 01:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2966) `Dukestar69:fix/watch-empty-ranges` → `main` · +34 −0 · 1 files · 1 commits · open ## Summary Short-circuit zero-length (`len == 0`) ranges in `watch::writing`, `Drop for Writing`, and `watch::title_memory_remapped` so 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 - Added regression test `unaligned_zero_length_writes_and_remaps_do_not_dirty_or_unlink` in `crates/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).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:18:50 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 05:29 UTC · original

Automated triage for the maintainers.

This fixes #2011 in crates/victory-gpu/src/watch.rs. With a zero length and an unaligned start, writing and title_memory_remapped round 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 for len == 0, and Drop for Writing skips the empty range. A non-empty range always has first < last, so real writes are unaffected. Zero lengths can happen in practice: writing takes the title's fread size times count, and the callers in shadow.rs/list.rs pass 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

**@⁠Marvisak** on GitHub · 2026-11-26 05:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2966#issuecomment-7183525759) <!-- victory-triage v1 head=b6b63384fe43d0fd6bb6b42bacf8d306699cd841 verdict=merge-candidate at=2026-11-26T05:28:52Z --> Automated triage for the maintainers. This fixes #2011 in `crates/victory-gpu/src/watch.rs`. With a zero length and an unaligned start, `writing` and `title_memory_remapped` round 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 for `len == 0`, and `Drop for Writing` skips the empty range. A non-empty range always has `first < last`, so real writes are unaffected. Zero lengths can happen in practice: `writing` takes the title's `fread` size times count, and the callers in `shadow.rs`/`list.rs` pass 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](https://claude.ai/code)_
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 08:50 UTC · original

Independent local verification of head b6b6338 on 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).

**@⁠cloph-dsp** on GitHub · 2026-11-26 08:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2966#issuecomment-7187085483) Independent local verification of head `b6b6338` on 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).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2966/head:github-bot/gh-2966'
git switch 'github-bot/gh-2966'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2966'
git switch 'github-bot/gh-2966'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2966'
git switch 'github-bot/gh-2966'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2966'
git switch 'main'
git merge --squash 'github-bot/gh-2966'
git switch 'main'
git merge --ff-only 'github-bot/gh-2966'
git switch 'main'
git merge 'github-bot/gh-2966'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2966
No description provided.