GPU watch: ignore zero-length writes and remaps on unaligned addresses (#2011) #2019
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2021"
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 DenRakEiw on 2026-11-25T03:16:21Z.
Fixes #2011.
Credit to @tyr0nsur for the clear bug report and reproduction in #2011, and to @matheusfrta for earlier work on empty-range guard cases in #991.
In
crates/victory-gpu/src/watch.rs,writing(at, len)andtitle_memory_remapped(at, len)computed(first, last) = (at / PAGE, at.saturating_add(len).div_ceil(PAGE)). Whenlen == 0andatis not page-aligned (e.g.base + 1), roundingstartdown andendup produced a 1-page rangep..p+1:writing(base + 1, 0)marked a clean page and its aliases dirty and held them inbusyuntil drop.title_memory_remapped(base + 1, 0)evicted live alias links for that page fromalias_of.Fix
len == 0inwriting(returning an emptyWriting { first: 0, last: 0 }),Drop for Writing(if self.first >= self.last { return; }), andtitle_memory_remapped.watch::tests::unaligned_zero_length_writes_and_remaps_do_not_dirty_or_unlinkverifying that an unaligned 0-byte write (both while the guard lives and after drop) and an unaligned 0-byte remap leave a clean page and its alias untouched, and that a subsequent real 1-byte write still dirties the alias.Verified locally on Windows 11 x64 (Rust 1.98.1 MSVC):
cargo test -p victory-gpu --lib watch::— 7 passed, 0 failedcargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:33:15Z.
Review: COMMENTED
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
GPU watch ignores zero-length writes and unaligned remaps (#20…) — watch-mode noise reduction; safe if the filters are exact.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T03:20:44Z.
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
7564b3c.victory-gpu: 142 passed, 2 failed, 2 ignored; the newunaligned_zero_length_writes_and_remaps_do_not_dirty_or_unlinkpasses. The 2 are #1744's NVIDIA failures onmain(dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views, the heap-cap ones). Same asmainon this hardware. Not run: a title.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T03:19:48Z.
Triage verdict — Ready for maintainer decision (
7564b3c)Evidence
Writingguard exits before taking the lock on drop.Checks and limits
Next step
This verification was AI-assisted.
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T04:44:50Z.
Verified on Windows 10 19045 (RX 7800 XT), head
7564b3c:cargo test -p victory-gpu --features diagnostics --lib watch::— 7 passed, 0 failed, includingunaligned_zero_length_writes_and_remaps_do_not_dirty_or_unlink.The fix reads right: with
len == 0,first == lastand the guard would previously remove a busy entry it never inserted (or mark pages as written by a zero-byte write), which is exactly what the aliasing tests then see as an unlink. The early returns are the narrow fix, and the test covers the “real 1-byte write afterwards still works” case, which is the one that would regress if the early return were misplaced.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:18:21Z.
Automated triage for the maintainers.
Merge candidate. In
crates/victory-gpu/src/watch.rs,writingandtitle_memory_remappednow return early whenlen == 0, andDrop for Writingskips an empty range. Inmain, an unaligned empty range (at / PAGE..(at + 0).div_ceil(PAGE)) rounds to one whole page. That dirties the page and its aliases, or removes the alias links (#2011). Recommending a look, not approving.What I checked:
Writing { first: 0, last: 0 }is never pushed tobusy, and its drop now never takes the lock or searchesbusy.fread-style kernel writes and the DirectStorage destination path pass a title-supplied length.CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-26T00:53:55Z.
Closing this PR — stepping back from code contributions on this account. Feel free to reuse the approach if helpful.
Pull request closed