GPU: fix 8 overflow, lookup, and snapshot bugs in shadow.rs with regression tests #906

Open
opened 2026-11-26 04:14:08 +00:00 by github-bot · 2 comments
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 13:52 UTC · original

Summary

Fixes 8 real overflow/underflow, buffer-lookup, and snapshot-consistency bugs in crates/victory-gpu/src/shadow.rs (previously 0 unit tests) and adds 8 synthetic regression tests proving each invariant.

Because external PR creation is currently restricted (collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:

  • Branch: geiyiliyabumo/VIctory@test/gpu-shadow-tests
  • Commit: geiyiliyabumo/VIctory@c1dd5b1 (based on main ffe310e)

Bugs Fixed (crates/victory-gpu/src/shadow.rs)

  1. register: start + len u64 overflow -> checked_add (reject overflowing registrations).
  2. loose: window next_multiple_of overflow -> checked_next_multiple_of + checked_sub.
  3. find: .take(64) could stop before reaching an earlier covering buffer -> unbounded start-descending scan.
  4. find: equal-start buffers could return a larger covering buffer instead of the tightest -> choose smallest end among equal starts.
  5. refresh: start + len - address underflow when address is past end -> use self.left(address).
  6. inside / writing / copy_back / update: address + len usize overflow -> saturating_add.
  7. writing: newly declared gap retained stale baseline -> re-snapshot declared range and dedupe via pending.
  8. copy_back: overlapping copy-backs could replay an earlier CPU edit -> refresh snapshot after copy-back.

Verification (Windows 11 x64 MSVC, AMD Radeon RX 9060 XT RDNA4 + WARP)

  • rustfmt --edition 2024 --check crates/victory-gpu/src/shadow.rs: PASS
  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-gpu --features diagnostics --locked -- shadow:: (live RX 9060 XT): 8 passed, 0 failed
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- shadow::: 8 passed, 0 failed

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 13:52 UTC · [original](https://github.com/Marvisak/VIctory/issues/906) ### Summary Fixes 8 real overflow/underflow, buffer-lookup, and snapshot-consistency bugs in `crates/victory-gpu/src/shadow.rs` (previously 0 unit tests) and adds 8 synthetic regression tests proving each invariant. Because external PR creation is currently restricted (`collaborators_only`), the CI-green branch is ready on my fork for cherry-pick / review: - **Branch**: `geiyiliyabumo/VIctory@test/gpu-shadow-tests` - **Commit**: `geiyiliyabumo/VIctory@c1dd5b1` (based on `main` `ffe310e`) ### Bugs Fixed (`crates/victory-gpu/src/shadow.rs`) 1. `register`: `start + len` `u64` overflow -> `checked_add` (reject overflowing registrations). 2. `loose`: window `next_multiple_of` overflow -> `checked_next_multiple_of` + `checked_sub`. 3. `find`: `.take(64)` could stop before reaching an earlier covering buffer -> unbounded start-descending scan. 4. `find`: equal-start buffers could return a larger covering buffer instead of the tightest -> choose smallest `end` among equal starts. 5. `refresh`: `start + len - address` underflow when `address` is past end -> use `self.left(address)`. 6. `inside` / `writing` / `copy_back` / `update`: `address + len` `usize` overflow -> `saturating_add`. 7. `writing`: newly declared gap retained stale baseline -> re-snapshot declared range and dedupe via `pending`. 8. `copy_back`: overlapping copy-backs could replay an earlier CPU edit -> refresh snapshot after copy-back. ### Verification (Windows 11 x64 MSVC, AMD Radeon RX 9060 XT RDNA4 + WARP) - `rustfmt --edition 2024 --check crates/victory-gpu/src/shadow.rs`: **PASS** - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-gpu --features diagnostics --locked -- shadow::` (live RX 9060 XT): **8 passed, 0 failed** - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- shadow::`: **8 passed, 0 failed** *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:08 +00:00
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-24 14:15 UTC · original

Independent verification of c1dd5b1 (geiyiliyabumo/VIctory@test/gpu-shadow-tests, fast-forward on main ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP:

  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics -- shadow:: --nocapture: 8 passed, 0 failed (all 6 shadow::warp_tests::* and both shadow::tests::* executed and passed)
  • cargo test -p victory-gpu --features diagnostics (RTX 5090): 61 passed, 0 failed, 1 ignored (note: the 6 shadow::warp_tests::* skip unless VICTORY_D3D12_WARP is set)
  • cargo clippy -p victory-gpu --features diagnostics --all-targets: 0 warnings
  • cargo xtask policy: ok

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-24 14:15 UTC · [original](https://github.com/Marvisak/VIctory/issues/906#issuecomment-7134086747) Independent verification of `c1dd5b1` (`geiyiliyabumo/VIctory@test/gpu-shadow-tests`, fast-forward on `main` `ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC) with **NVIDIA GeForce RTX 5090** (Blackwell) and **WARP**: - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics -- shadow:: --nocapture`: **8 passed, 0 failed** (all 6 `shadow::warp_tests::*` and both `shadow::tests::*` executed and passed) - `cargo test -p victory-gpu --features diagnostics` (RTX 5090): **61 passed, 0 failed, 1 ignored** *(note: the 6 `shadow::warp_tests::*` skip unless `VICTORY_D3D12_WARP` is set)* - `cargo clippy -p victory-gpu --features diagnostics --all-targets`: **0 warnings** - `cargo xtask policy`: ok AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:59 UTC · original

Automated triage for the maintainers.

The pull request for this branch, #1186, was already reviewed and closed: crates/victory-gpu/src/shadow.rs has largely been replaced on main since ffe310e, and most of the eight guards are for cases that cannot occur. The two changes that still matter are in focused open PRs: #402 (finding a buffer past many smaller ones) and #261 (copy-back keeping newer title bytes). Please follow those; if something here is not covered by them, a small PR against current main with a failing test is the way to raise it.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:59 UTC · [original](https://github.com/Marvisak/VIctory/issues/906#issuecomment-7155367979) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T14:15:32Z at=2026-11-25T06:59:22Z --> Automated triage for the maintainers. The pull request for this branch, #1186, was already reviewed and closed: `crates/victory-gpu/src/shadow.rs` has largely been replaced on `main` since `ffe310e`, and most of the eight guards are for cases that cannot occur. The two changes that still matter are in focused open PRs: #402 (finding a buffer past many smaller ones) and #261 (copy-back keeping newer title bytes). Please follow those; if something here is not covered by them, a small PR against current `main` with a failing test is the way to raise it. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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#906
No description provided.