Use checked addition and forward-progress guards in committed memory queries #455

Closed
github-bot wants to merge 660 commits from github-bot/gh-455 into main AGit
Owner

@⁠ahmetbagci8 on GitHub · 2026-11-29 18:19 UTC · original
ahmetbagci8:fix/gpu-committed-checked-add → main · +60038 −5432 · 206 files · 660 commits · closed without merging

Problem

In crates/victory-gpu/src/texture.rs (committed_by_query) and crates/victory-gpu/src/port.rs (committed):

  1. p + len / t + len uses unchecked addition — overflowing ranges panic in debug builds and wrap end < at in release builds, skipping the loop and falsely returning rue.
  2. Neither loop verifies forward progress (
    ext <= p /
    ext <= here), and committed_by_query also uses unchecked BaseAddress as usize + RegionSize.

Fix

Use checked_add(len) (returning alse on overflow), saturating_add(info.RegionSize), and a
ext <= p /
ext <= here forward-progress guard in both functions, with unit tests (committed_by_query_rejects_overflowing_range and committed_rejects_overflowing_range).

Verification

  • cargo test -p victory-gpu --lib -- committed_by_query_rejects_overflowing_range port::tests (4 passed, 0 failed)
  • cargo clippy -p victory-gpu --tests (0 warnings)
**@⁠ahmetbagci8** on GitHub · 2026-11-29 18:19 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/455) `ahmetbagci8:fix/gpu-committed-checked-add` → `main` · +60038 −5432 · 206 files · 660 commits · closed without merging ## Problem In crates/victory-gpu/src/texture.rs (committed_by_query) and crates/victory-gpu/src/port.rs (committed): 1. p + len / t + len uses unchecked addition — overflowing ranges panic in debug builds and wrap end < at in release builds, skipping the loop and falsely returning rue. 2. Neither loop verifies forward progress ( ext <= p / ext <= here), and committed_by_query also uses unchecked BaseAddress as usize + RegionSize. ## Fix Use checked_add(len) (returning alse on overflow), saturating_add(info.RegionSize), and a ext <= p / ext <= here forward-progress guard in both functions, with unit tests (committed_by_query_rejects_overflowing_range and committed_rejects_overflowing_range). ## Verification - cargo test -p victory-gpu --lib -- committed_by_query_rejects_overflowing_range port::tests (4 passed, 0 failed) - cargo clippy -p victory-gpu --tests (0 warnings)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 18:23:35 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-29 19:09 UTC · original

Thanks for guarding both the range end and the VirtualQuery loop's forward progress. Rejecting overflow before querying is the right behavior. Please retain normal committed/uncommitted range coverage as well as the new overflow cases; I haven't run the consolidated tests yet.

**@⁠TaynanGT** on GitHub · 2026-11-29 19:09 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/455#issuecomment-7261052122) Thanks for guarding both the range end and the VirtualQuery loop's forward progress. Rejecting overflow before querying is the right behavior. Please retain normal committed/uncommitted range coverage as well as the new overflow cases; I haven't run the consolidated tests yet.
github-bot closed this pull request 2026-11-30 17:08:29 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-30 17:05 UTC · original

main has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current main and open a new PR; I'll review it there.

**@⁠TaynanGT** on GitHub · 2026-11-30 17:05 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/455#issuecomment-7285709819) `main` has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current `main` and open a new PR; I'll review it there.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.