Capture: avoid overflow in world-relative frame matching #3482

Open
github-bot wants to merge 1 commit from github-bot/gh-3482 into main AGit
Owner

@⁠playcations on GitHub · 2026-11-27 07:31 UTC · original
playcations:fix/capture-world-offset-overflow → main · +32 −1 · 1 files · 1 commits · open

A large accepted VICTORY_CAPTURE_WORLD offset can overflow anchor + offset after the world anchor is established: checked builds panic, while wrapping builds can match a frame before that anchor. Match the checked frame difference against the offsets so all representable targets, including u64::MAX, keep their meaning.

The change is limited to capture.rs. Its pure tests avoid environment mutation and the process-global OnceLocks; absolute frame selection and power-of-two captures retain their existing behavior.

Validation:

  • Independent native Windows verification: all eight capture tests passed. Fresh-process selector checks passed with overflow checks on and off, including absolute/power-of-two selection, world anchoring, unset offsets, and trace selection with PNG output disabled (CPU-only).
  • Three focused Windows-target diagnostics tests passed under GPU-isolated Wine 11.22 Staging.
  • The extracted production matcher passed the same boundary cases with overflow checks enabled and disabled; the original arithmetic failed both controls (overflow panic / before-anchor alias).
  • Windows-target Clippy with diagnostics and -D warnings, the asset policy, and git diff --check passed. Separate Sol source review found no material issue.

Reproduce the three new CPU tests on Windows with cargo test --locked -p victory-gpu --lib --features diagnostics -- capture::tests::world_frames_ --test-threads=1. The diagnostics feature is required to compile the capture module.

Claim: #1633. The broad fork in #2643 also changes this selector; its wrapping-subtraction variant retains the before-anchor case covered here. This patch preserves current main's capture contract.

AI-assisted with Codex GPT-6.1 Sol. Synthetic CPU tests only; no game data.

**@⁠playcations** on GitHub · 2026-11-27 07:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/3482) `playcations:fix/capture-world-offset-overflow` → `main` · +32 −1 · 1 files · 1 commits · open A large accepted `VICTORY_CAPTURE_WORLD` offset can overflow `anchor + offset` after the world anchor is established: checked builds panic, while wrapping builds can match a frame before that anchor. Match the checked frame difference against the offsets so all representable targets, including `u64::MAX`, keep their meaning. The change is limited to `capture.rs`. Its pure tests avoid environment mutation and the process-global `OnceLock`s; absolute frame selection and power-of-two captures retain their existing behavior. Validation: - [Independent native Windows verification](https://git.gtahub.st/github/Marvisak--VIctory/pulls/3482): all eight capture tests passed. Fresh-process selector checks passed with overflow checks on and off, including absolute/power-of-two selection, world anchoring, unset offsets, and trace selection with PNG output disabled (CPU-only). - Three focused Windows-target diagnostics tests passed under GPU-isolated Wine 11.22 Staging. - The extracted production matcher passed the same boundary cases with overflow checks enabled and disabled; the original arithmetic failed both controls (overflow panic / before-anchor alias). - Windows-target Clippy with diagnostics and `-D warnings`, the asset policy, and `git diff --check` passed. Separate Sol source review found no material issue. Reproduce the three new CPU tests on Windows with `cargo test --locked -p victory-gpu --lib --features diagnostics -- capture::tests::world_frames_ --test-threads=1`. The `diagnostics` feature is required to compile the capture module. Claim: https://git.gtahub.st/github/Marvisak--VIctory/issues/1633. The broad fork in #2643 also changes this selector; its wrapping-subtraction variant retains the before-anchor case covered here. This patch preserves current main's capture contract. AI-assisted with Codex GPT-6.1 Sol. Synthetic CPU tests only; no game data.
Use a checked difference so offsets beyond the frame counter cannot panic or wrap to a frame before the world anchor. Add pure boundary regressions without changing environment variables or OnceLocks. AI-assisted with Codex GPT-6.1 Sol.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 07:33:56 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-27 08:48 UTC · original

Native Windows verification on 1a756dc. All 8 capture tests passed, including the 3 new world-offset cases.

I also ran the frame selector from each revision in fresh Windows processes with synthetic draw counts. Both builds of the PR (overflow checks on and off) kept the absolute frame and power-of-two captures, anchored the first frame with 500 draws, and selected offsets 0 and 5 from that anchor. With u64::MAX first in the offset list, main either panicked or selected the frame immediately before the anchor. The PR rejected that frame in both builds and still selected u64::MAX when the target was representable.

The selector fixture also covered unset world offsets and trace selection with PNG output disabled. It exercised frame selection on the CPU. AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-27 08:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/3482#issuecomment-7213936064) Native Windows verification on `1a756dc`. All 8 capture tests passed, including the 3 new world-offset cases. I also ran the frame selector from each revision in fresh Windows processes with synthetic draw counts. Both builds of the PR (overflow checks on and off) kept the absolute frame and power-of-two captures, anchored the first frame with 500 draws, and selected offsets 0 and 5 from that anchor. With `u64::MAX` first in the offset list, main either panicked or selected the frame immediately before the anchor. The PR rejected that frame in both builds and still selected `u64::MAX` when the target was representable. The selector fixture also covered unset world offsets and trace selection with PNG output disabled. It exercised frame selection on the CPU. AI-assisted with Codex.
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-27 09:05 UTC · original

Independent CPU-only verification of PR #3482 (world-frame wrap).

  • Windows, rustc/cargo 1.100.0/MSVC, worktree-local CARGO_TARGET_DIR (D:\Victory-Contrib\target-3482-verify), CARGO_BUILD_JOBS=2.
  • Head 1a756dcc9e9e40186d365376f4710b15f19efa6d, merge base 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • capture is gated #[cfg(all(windows, feature = "diagnostics"))]; --features diagnostics is required (the first run without it matched 0 tests).
  • Command: cargo test --locked -p victory-gpu --lib --features diagnostics -- capture::tests::world_frames_before_anchor_do_not_wrap --exact --test-threads=1 --quiet -> 1 passed; 0 failed; 249 filtered out.
  • Negative control: git grep -F for the new test name on 63bcca4 returned no hits (test absent on base).
  • git diff --check 63bcca4 HEAD exit 0 (clean).
  • Only the named synthetic test was replayed; real capture data was not used. Only pre-existing fetch_update deprecation warnings.
  • AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only). No game data, assets, shaders, DRM or decrypt used.
**@⁠cloph-dsp** on GitHub · 2026-11-27 09:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/3482#issuecomment-7214274399) Independent CPU-only verification of PR #3482 (`world-frame wrap`). - Windows, rustc/cargo 1.100.0/MSVC, worktree-local `CARGO_TARGET_DIR` (`D:\Victory-Contrib\target-3482-verify`), `CARGO_BUILD_JOBS=2`. - Head `1a756dcc9e9e40186d365376f4710b15f19efa6d`, merge base `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - `capture` is gated `#[cfg(all(windows, feature = "diagnostics"))]`; `--features diagnostics` is required (the first run without it matched 0 tests). - Command: `cargo test --locked -p victory-gpu --lib --features diagnostics -- capture::tests::world_frames_before_anchor_do_not_wrap --exact --test-threads=1 --quiet` -> `1 passed; 0 failed; 249 filtered out`. - Negative control: `git grep -F` for the new test name on `63bcca4` returned no hits (test absent on base). - `git diff --check 63bcca4 HEAD` exit 0 (clean). - Only the named synthetic test was replayed; real capture data was not used. Only pre-existing `fetch_update` deprecation warnings. - AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only). No game data, assets, shaders, DRM or decrypt used.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-27 18:37 UTC · original

NVIDIA full-suite run, to go with the reports above by cloph-dsp, since none of them names a GPU run. Tested exact head 1a756dc (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 866 passed, 0 failed, 10 ignored.
  • world_frames_match_zero_and_later_offsets_beside_maximum, world_frames_before_anchor_do_not_wrap, world_frames_keep_the_largest_representable_target only build with the diagnostics feature, so the run above doesn't include them; they pass in cargo test -p victory-core -p victory-gpu -p victory-hle -p victory-loader -p victory-shader -p victory --lib --locked --features victory-core/diagnostics,victory-gpu/diagnostics,victory-hle/diagnostics,victory-loader/diagnostics,victory-shader/diagnostics,victory/diagnostics (same skips).
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-27 18:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/3482#issuecomment-7225683642) NVIDIA full-suite run, to go with the reports above by cloph-dsp, since none of them names a GPU run. Tested exact head `1a756dc` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **866 passed, 0 failed, 10 ignored**. - `world_frames_match_zero_and_later_offsets_beside_maximum`, `world_frames_before_anchor_do_not_wrap`, `world_frames_keep_the_largest_representable_target` only build with the `diagnostics` feature, so the run above doesn't include them; they pass in `cargo test -p victory-core -p victory-gpu -p victory-hle -p victory-loader -p victory-shader -p victory --lib --locked --features victory-core/diagnostics,victory-gpu/diagnostics,victory-hle/diagnostics,victory-loader/diagnostics,victory-shader/diagnostics,victory/diagnostics` (same skips). - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3482/head:github-bot/gh-3482'
git switch 'github-bot/gh-3482'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3482'
git switch 'github-bot/gh-3482'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3482'
git switch 'github-bot/gh-3482'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3482'
git switch 'main'
git merge --squash 'github-bot/gh-3482'
git switch 'main'
git merge --ff-only 'github-bot/gh-3482'
git switch 'main'
git merge 'github-bot/gh-3482'
git push origin 'main'
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!3482
No description provided.