GPU: handle empty and inverted ranges in watch::writes, writing, and title_memory_remapped #1332

Closed
github-bot wants to merge 1 commit from gh-pr/1332/head into gh-pr/1332/base
Owner

@⁠mgunes1311-lab on GitHub · 2026-11-24 17:30 UTC · original
mgunes1311-lab:gpu-watch-empty-ranges → main · +76 −7 · 1 files · 1 commits · closed without merging

Fixes guard corruption and integer underflow on empty, unaligned-empty, and inverted byte/address ranges in crates/victory-gpu/src/watch.rs:

Changes

  • Early-return on len == 0 in writing and title_memory_remapped: an unaligned empty range previously rounded to a nonempty block range. writing unnecessarily opened and dirtied that block. title_memory_remapped could remove its protection bookkeeping while the OS mapping remained read-only, so the next write fault was no longer recognized by on_write.
  • Early-return false in open when start >= end so BTreeSet::range cannot panic on inverted bounds.
  • Early-return Some((j.asked, Vec::new())) in writes when start >= end (avoiding last - first underflow or GetWriteWatch(..., size = 0) failure), and use last.saturating_mul(PAGE) when delegating to guard.
  • Added synthetic test 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 warnings
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --target x86_64-pc-windows-msvc --locked
  • cargo run -p xtask --target x86_64-pc-windows-msvc --locked -- policy --staged (asset policy: 1 files ok)
**@⁠mgunes1311-lab** on GitHub · 2026-11-24 17:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1332) `mgunes1311-lab:gpu-watch-empty-ranges` → `main` · +76 −7 · 1 files · 1 commits · closed without merging Fixes guard corruption and integer underflow on empty, unaligned-empty, and inverted byte/address ranges in `crates/victory-gpu/src/watch.rs`: ### Changes - Early-return on `len == 0` in `writing` and `title_memory_remapped`: an unaligned empty range previously rounded to a nonempty block range. `writing` unnecessarily opened and dirtied that block. `title_memory_remapped` could remove its protection bookkeeping while the OS mapping remained read-only, so the next write fault was no longer recognized by `on_write`. - Early-return `false` in `open` when `start >= end` so `BTreeSet::range` cannot panic on inverted bounds. - Early-return `Some((j.asked, Vec::new()))` in `writes` when `start >= end` (avoiding `last - first` underflow or `GetWriteWatch(..., size = 0)` failure), and use `last.saturating_mul(PAGE)` when delegating to `guard`. - Added synthetic test `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 warnings` - `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --target x86_64-pc-windows-msvc --locked` - `cargo run -p xtask --target x86_64-pc-windows-msvc --locked -- policy --staged` (`asset policy: 1 files ok`)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:53 +00:00
github-bot closed this pull request 2026-11-26 04:27:53 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:37 UTC · original

Automated triage for the maintainers. Closing because this change is already in main, or main has 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.

**@⁠Marvisak** on GitHub · 2026-11-25 00:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/1332#issuecomment-7148709854) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has 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

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!1332
No description provided.