GPU: handle empty and inverted ranges in watch::writes, writing, and title_memory_remapped #1332
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1332"
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 mgunes1311-lab on 2026-11-24T17:30:20Z.
Fixes guard corruption and integer underflow on empty, unaligned-empty, and inverted byte/address ranges in
crates/victory-gpu/src/watch.rs:Changes
len == 0inwritingandtitle_memory_remapped: an unaligned empty range previously rounded to a nonempty block range.writingunnecessarily opened and dirtied that block.title_memory_remappedcould remove its protection bookkeeping while the OS mapping remained read-only, so the next write fault was no longer recognized byon_write.falseinopenwhenstart >= endsoBTreeSet::rangecannot panic on inverted bounds.Some((j.asked, Vec::new()))inwriteswhenstart >= end(avoidinglast - firstunderflow orGetWriteWatch(..., size = 0)failure), and uselast.saturating_mul(PAGE)when delegating toguard.empty_and_inverted_ranges_do_not_corrupt_guards_or_underflow.Verification
cargo test -p victory-gpu --target x86_64-pc-windows-msvc --locked watch::(4 passed; 0 failed)cargo clippy --workspace --all-targets --target x86_64-pc-windows-msvc --locked -- -D warningsRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --target x86_64-pc-windows-msvc --lockedcargo run -p xtask --target x86_64-pc-windows-msvc --locked -- policy --staged(asset policy: 1 files ok)Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:07:45Z.
Review: COMMENTED
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS, so this is source review plus the PR's own Windows tests.
Empty and inverted ranges are handled before any page math:
writesreturns early forstart >= end,guarduseslast.saturating_mul(PAGE)instead of plain multiplication, andopen/writing/title_memory_remappedall no-op on empty ranges. This removes the underflow/OOB that an inverted range (end < start) would have caused inlast - first. The new test maps a real pagefile section, guards it, verifies empty/inverted ranges don't disturb guards, and confirms the VEH write-watch still fires for the guarded block. Windows-only; looks correct.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:37:39Z.
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Guards the old watch::writes and open against empty and inverted ranges; both are gone, and in main an empty range at worst marks one page changed.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed