Use checked subtraction in port_descriptors::missed #459

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

@⁠ahmetbagci8 on GitHub · 2026-11-29 20:48 UTC · original
ahmetbagci8:fix/gpu-port-descriptors-missed-underflow → main · +60026 −5429 · 206 files · 660 commits · closed without merging

Problem

In crates/victory-gpu/src/port_descriptors.rs, missed() computes ((handle - a.start) >> 16) as usize with unchecked subtraction. If missed() is called with a handle < a.start (for example a handle from another heap), handle - a.start panics with integer underflow in debug builds.

Fix

Use handle.checked_sub(a.start).and_then(|d| a.writers.get((d >> 16) as usize)) and add unit test missed_handles_address_below_adopted_heap_start.

Verification

  • cargo test -p victory-gpu --lib port_descriptors::tests (5 passed, 0 failed)
  • cargo clippy -p victory-gpu --tests (0 warnings)
**@⁠ahmetbagci8** on GitHub · 2026-11-29 20:48 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/459) `ahmetbagci8:fix/gpu-port-descriptors-missed-underflow` → `main` · +60026 −5429 · 206 files · 660 commits · closed without merging ## Problem In crates/victory-gpu/src/port_descriptors.rs, missed() computes ((handle - a.start) >> 16) as usize with unchecked subtraction. If missed() is called with a handle < a.start (for example a handle from another heap), handle - a.start panics with integer underflow in debug builds. ## Fix Use handle.checked_sub(a.start).and_then(|d| a.writers.get((d >> 16) as usize)) and add unit test missed_handles_address_below_adopted_heap_start. ## Verification - cargo test -p victory-gpu --lib port_descriptors::tests (5 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 20:51:43 +00:00
github-bot closed this pull request 2026-11-30 17:08:27 +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/459#issuecomment-7285701888) `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.