XGameSave: refuse an update when no version number is above the highest (#2497) #2511

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

@⁠Creaa on GitHub · 2026-11-25 15:03 UTC · original
Creaa:hle/xgamesave-version-overflow → main · +21 −1 · 1 files · 1 commits · open

An update whose container folder holds a stray v18446744073709551615 next to a committed v1 lost the save in release builds: the next version number highest + 1 wrapped to 0, the update committed v0 (not a canonical version, so reads ignore it), returned S_OK and removed v1. In debug builds it panicked on the addition. The update is now refused with NO_ACCESS (what an unreadable container already returns) before anything is written or removed. Fixes #2497.

What is in it

  • crates/victory-hle/src/modules/xgamesave.rs: Update::submit takes the next number with highest.checked_add(1) and returns NO_ACCESS when there is none.
  • Test no_version_above_the_highest_number_is_refused_and_kept: a committed v1 and a stray v18446744073709551615; the update returns NO_ACCESS, the save reads as before, v1 stays and no v0 appears.

Tested

  • Windows 11 build 26300, i7-13700F, RTX 4070, Rust 1.100.0.
  • The new test without the fix: debug panics at the addition (xgamesave.rs:511), release fails with left: 0, right: -2138898430 (S_OK instead of NO_ACCESS). With the fix it passes in both; the 12 xgamesave tests pass in debug and release.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
  • cargo test --workspace --locked --no-fail-fast: 697 passed, 5 failed, 10 ignored. The 5 fail the same way on main 940d32f on this NVIDIA card and are outside this change: victory-gpu dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views; victory-shader a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, gathers_at_a_level_match_the_hardware (the same five as in #1744 on an RTX 5070).

Not tested

  • A save folder from a real title with such a stray folder: the case is made by the test. The separate case the issue mentions (a valid manifest with missing blobs) is not changed here.

AI use

  • Claude Code (Claude Opus 5.5) wrote the change and the test, ran them, and drafted this description; I checked it.

🤖 Generated with Claude Code

**@⁠Creaa** on GitHub · 2026-11-25 15:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2511) `Creaa:hle/xgamesave-version-overflow` → `main` · +21 −1 · 1 files · 1 commits · open An update whose container folder holds a stray `v18446744073709551615` next to a committed `v1` lost the save in release builds: the next version number `highest + 1` wrapped to 0, the update committed `v0` (not a canonical version, so reads ignore it), returned `S_OK` and removed `v1`. In debug builds it panicked on the addition. The update is now refused with `NO_ACCESS` (what an unreadable container already returns) before anything is written or removed. Fixes #2497. **What is in it** - `crates/victory-hle/src/modules/xgamesave.rs`: `Update::submit` takes the next number with `highest.checked_add(1)` and returns `NO_ACCESS` when there is none. - Test `no_version_above_the_highest_number_is_refused_and_kept`: a committed `v1` and a stray `v18446744073709551615`; the update returns `NO_ACCESS`, the save reads as before, `v1` stays and no `v0` appears. **Tested** - Windows 11 build 26300, i7-13700F, RTX 4070, Rust 1.100.0. - The new test without the fix: debug panics at the addition (`xgamesave.rs:511`), release fails with `left: 0, right: -2138898430` (`S_OK` instead of `NO_ACCESS`). With the fix it passes in both; the 12 `xgamesave` tests pass in debug and release. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - `cargo test --workspace --locked --no-fail-fast`: 697 passed, 5 failed, 10 ignored. The 5 fail the same way on `main` `940d32f` on this NVIDIA card and are outside this change: `victory-gpu` `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`; `victory-shader` `a_heap_buffer_read_by_element_takes_the_views_stride`, `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `gathers_at_a_level_match_the_hardware` (the same five as in #1744 on an RTX 5070). **Not tested** - A save folder from a real title with such a stray folder: the case is made by the test. The separate case the issue mentions (a valid manifest with missing blobs) is not changed here. **AI use** - Claude Code (Claude Opus 5.5) wrote the change and the test, ran them, and drafted this description; I checked it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With a stray `v18446744073709551615` folder next to a committed `v1`, the
next number `highest + 1` overflowed: a debug build panicked, and a release
build wrapped to 0, committed `v0` (not canonical, so never read), returned
S_OK and removed `v1`, losing the save. The number now comes from
`checked_add`; with none, the update returns NO_ACCESS, as for a container
with no readable version, before anything is written or removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:07:52 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 15:37 UTC · original

Verification (Windows 11, WARP/CPU only) — head b730d1e5ffd5173146b5ba745cdc3dd4f64c99a9, with overlap against #2525

Tested: the PR head = origin/main 940d32f + the PR (merge-base 940d32f, fast-forward). Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1. VICTORY_D3D12_WARP=1 with --features diagnostics for victory-hle (it enables victory-gpu/diagnostics, so any host device is WARP); the xgamesave code itself is filesystem-only. No physical GPU.

command result
cargo test -p victory-hle --locked --features diagnostics --lib xgamesave -- --test-threads=1 12 passed, 0 failed
... --lib no_version_above 1 passed
same test against origin/main's production code (test kept) fails: panics at xgamesave.rs:511 (highest + 1 overflow; wraps to v0 in a release build, as #2497 describes)
cargo test -p victory-hle --locked --features diagnostics --lib -- --test-threads=1 144 passed, 0 failed, 0 ignored
cargo clippy -p victory-hle --all-targets [--features diagnostics] --locked -- -D warnings clean
cargo xtask policy asset policy: 182 files ok

Diff read: checked_add(1) on highest returns NO_ACCESS before commit/removal, so nothing is written or removed; the no-save path (Some(1)) is unchanged. The test asserts the refusal, that state is unchanged, v1 remains and v0 is never created. No findings.

Side by side with #2525 (head a805860e; both fix #2497, both only touch victory-hle/src/modules/xgamesave.rs)

  • Production overlap is the one number line in Update: both use highest.checked_add(1) with NO_ACCESS and the same intent; the two PRs conflict textually there (git merge conflict in that hunk only; their tests and #2525's other hunks merge cleanly).
  • Resolving that hunk either way (#2525's or #2511's side) with both PRs' tests: 13 xgamesave tests pass; with #2525's side the full lib is 145 passed, 0 failed, and clippy (diagnostics) is clean. So the two overlap fully on the overflow guard and tests; #2511 is the minimal version.
  • #2525 additionally changes load (a version whose listed blob files are missing or not files reads as unreadable), makes migrate stop (returns None) when a directory entry or blob read fails instead of silently skipping that blob, and extends an_unreadable_newer_version_does_not_cost_the_save with a "missing blob" case (fails on origin/main). That is beyond #2497's overflow and is not in this PR.

WARP-only caveat is moot for the filesystem logic; no real GPU used. Synthetic data only.

AI use: Claude Code (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-25 15:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2511#issuecomment-7167131638) **Verification (Windows 11, WARP/CPU only) — head `b730d1e5ffd5173146b5ba745cdc3dd4f64c99a9`, with overlap against #2525** Tested: the PR head = `origin/main` `940d32f` + the PR (merge-base `940d32f`, fast-forward). Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1. `VICTORY_D3D12_WARP=1` with `--features diagnostics` for `victory-hle` (it enables `victory-gpu/diagnostics`, so any host device is WARP); the xgamesave code itself is filesystem-only. No physical GPU. | command | result | |---|---| | `cargo test -p victory-hle --locked --features diagnostics --lib xgamesave -- --test-threads=1` | 12 passed, 0 failed | | `... --lib no_version_above` | 1 passed | | same test against `origin/main`'s production code (test kept) | **fails**: panics at `xgamesave.rs:511` (`highest + 1` overflow; wraps to `v0` in a release build, as #2497 describes) | | `cargo test -p victory-hle --locked --features diagnostics --lib -- --test-threads=1` | 144 passed, 0 failed, 0 ignored | | `cargo clippy -p victory-hle --all-targets [--features diagnostics] --locked -- -D warnings` | clean | | `cargo xtask policy` | `asset policy: 182 files ok` | Diff read: `checked_add(1)` on `highest` returns `NO_ACCESS` before `commit`/removal, so nothing is written or removed; the no-save path (`Some(1)`) is unchanged. The test asserts the refusal, that `state` is unchanged, `v1` remains and `v0` is never created. No findings. **Side by side with #2525 (head `a805860e`; both fix #2497, both only touch `victory-hle/src/modules/xgamesave.rs`)** - Production overlap is the one `number` line in `Update`: both use `highest.checked_add(1)` with `NO_ACCESS` and the same intent; the two PRs conflict textually there (git merge conflict in that hunk only; their tests and #2525's other hunks merge cleanly). - Resolving that hunk either way (#2525's or #2511's side) with both PRs' tests: 13 xgamesave tests pass; with #2525's side the full lib is 145 passed, 0 failed, and clippy (`diagnostics`) is clean. So the two overlap fully on the overflow guard and tests; #2511 is the minimal version. - #2525 additionally changes `load` (a version whose listed blob files are missing or not files reads as unreadable), makes `migrate` stop (returns `None`) when a directory entry or blob read fails instead of silently skipping that blob, and extends `an_unreadable_newer_version_does_not_cost_the_save` with a "missing blob" case (fails on `origin/main`). That is beyond #2497's overflow and is not in this PR. WARP-only caveat is moot for the filesystem logic; no real GPU used. Synthetic data only. AI use: Claude Code (Claude Sonnet 5.5).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:52 UTC · original

Automated triage for the maintainers. Merge candidate: in crates/victory-hle/src/modules/xgamesave.rs, Update::submit now takes the next version number with highest.checked_add(1) and returns NO_ACCESS before commit and before the old version is removed. On main, current() counts any v<N> entry (including a stray one) in highest, so highest + 1 really does overflow as described in #2497, and the new test covers that case. CI (check) passes. Note: #2525 changes the same line the same way and also handles missing blobs, so only one of the two should be merged.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2511#issuecomment-7167392817) <!-- victory-triage v1 head=b730d1e5ffd5173146b5ba745cdc3dd4f64c99a9 verdict=merge-candidate at=2026-11-25T15:52:21Z --> Automated triage for the maintainers. Merge candidate: in `crates/victory-hle/src/modules/xgamesave.rs`, `Update::submit` now takes the next version number with `highest.checked_add(1)` and returns `NO_ACCESS` before `commit` and before the old version is removed. On main, `current()` counts any `v<N>` entry (including a stray one) in `highest`, so `highest + 1` really does overflow as described in #2497, and the new test covers that case. CI (`check`) passes. Note: #2525 changes the same line the same way and also handles missing blobs, so only one of the two should be merged. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 02:08 UTC · original · reviewed

Reviewed and verified against main (63bcca43) on Windows 11 — clean fix for #2497 and ready to merge:

  • Using v.highest.checked_add(1) in Update::submit (crates/victory-hle/src/modules/xgamesave.rs:514-516) returns NO_ACCESS before writing or pruning prior versions when highest == u64::MAX, eliminating both release wraparound to v0 and debug overflow panic.

Local verification:

  • cargo test --locked -p victory-hle: 153/153 unit (including xgamesave 12/12 with no_version_above_the_highest_number_is_refused_and_kept) + 2/2 integration tests passed
  • cargo clippy --all-targets -p victory-hle -- -D warnings + cargo xtask policy (191 files ok): 0 warnings
**@⁠fuzeofficlal** on GitHub · 2026-11-26 02:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2511#pullrequestreview-6067611595) · **reviewed** Reviewed and verified against `main` (`63bcca43`) on Windows 11 — clean fix for #2497 and ready to merge: - Using `v.highest.checked_add(1)` in `Update::submit` (`crates/victory-hle/src/modules/xgamesave.rs:514-516`) returns `NO_ACCESS` before writing or pruning prior versions when `highest == u64::MAX`, eliminating both release wraparound to `v0` and debug overflow panic. **Local verification**: - `cargo test --locked -p victory-hle`: **153/153 unit** (including `xgamesave` **12/12** with `no_version_above_the_highest_number_is_refused_and_kept`) + **2/2 integration tests passed** - `cargo clippy --all-targets -p victory-hle -- -D warnings` + `cargo xtask policy` (`191 files ok`): 0 warnings
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 15:17 UTC · original

Independent verification (Windows, Rust 1.100.0/MSVC, head b730d1e, synthetic save directories only, no game data):

  • cargo test --locked -p victory-hle --lib -- modules::xgamesave::tests::no_version_above_the_highest_number_is_refused_and_kept --exact — 1 passed, 0 failed, 143 filtered.
  • git diff --check against merge base 940d32f — clean.
  • Per-worktree CARGO_TARGET_DIR used.

AI-assisted (Hy4 flash). GPU/driver: N/A (CPU only). Did not replay a real title save.

**@⁠cloph-dsp** on GitHub · 2026-11-26 15:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2511#issuecomment-7196055880) Independent verification (Windows, Rust 1.100.0/MSVC, head b730d1e, synthetic save directories only, no game data): - `cargo test --locked -p victory-hle --lib -- modules::xgamesave::tests::no_version_above_the_highest_number_is_refused_and_kept --exact` — 1 passed, 0 failed, 143 filtered. - `git diff --check` against merge base 940d32f — clean. - Per-worktree `CARGO_TARGET_DIR` used. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU only). Did not replay a real title save.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2511/head:github-bot/gh-2511'
git switch 'github-bot/gh-2511'

Merge

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