GPU watch: ignore zero-length writes and remaps on unaligned addresses (#2011) #2021
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!2021
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2021/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?
@DenRakEiw on GitHub · 2026-11-25 03:16 UTC · original
fix/watch-empty-ranges→main· +34 −0 · 1 files · 1 commits · closed without mergingFixes #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).
@jeremygold02 on GitHub · 2026-11-25 03:19 UTC · original · edited 2026-11-25 03:20 UTC
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.
@upipibi on GitHub · 2026-11-25 03:20 UTC · original
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).
@Calvix2k on GitHub · 2026-11-25 04:44 UTC · original
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.@Marvisak on GitHub · 2026-11-25 09:18 UTC · original
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
@DenRakEiw on GitHub · 2026-11-26 00:53 UTC · original
Closing this PR — stepping back from code contributions on this account. Feel free to reuse the approach if helpful.
Pull request closed