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

Open
Creaa wants to merge 1 commit from upstream-pr/2511 into main
Creaa commented 2026-11-25 15:03:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Creaa on 2026-11-25T15:03:54Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:5493878679 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2511). Originally posted by [Creaa](https://github.com/Creaa) on 2026-11-25T15:03:54Z. --- 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)
oni-swr commented 2026-11-25 16:09:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T15:37:34Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167131638 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2511#issuecomment-7167131638). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T15:37:34Z. --- **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).
Marvisak commented 2026-11-25 16:09:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:52:45Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167392817 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2511#issuecomment-7167392817). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:52:45Z. --- <!-- 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)_
fuzeofficlal commented 2026-11-26 02:08:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:08:28Z.

Review: COMMENTED


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
<!-- greyfinch-sync:Marvisak/VIctory:review:6067611595 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2511#pullrequestreview-6067611595). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T02:08:28Z. **Review:** COMMENTED --- 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
cloph-dsp commented 2026-11-26 16:05:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T15:17:25Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7196055880 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2511#issuecomment-7196055880). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T15:17:25Z. --- 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.
Dukestar69 commented 2026-11-27 01:30:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-27T01:30:53Z.

Review: APPROVED


LGTM — verified on Windows:

  • Using v.highest.checked_add(1) and returning NO_ACCESS cleanly prevents u64::MAX + 1 wraparound to v0 and preserves the committed save
  • cargo test -p victory-hle --lib xgamesave passed (12/12, including no_version_above_the_highest_number_is_refused_and_kept)
  • cargo clippy -p victory-hle --all-targets -- -D warnings passed with 0 warnings
  • cargo xtask policy passed (191 files ok)

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6082290764 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2511#pullrequestreview-6082290764). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-27T01:30:53Z. **Review:** APPROVED --- LGTM — verified on Windows: - Using `v.highest.checked_add(1)` and returning `NO_ACCESS` cleanly prevents `u64::MAX + 1` wraparound to `v0` and preserves the committed save - `cargo test -p victory-hle --lib xgamesave` passed (12/12, including `no_version_above_the_highest_number_is_refused_and_kept`) - `cargo clippy -p victory-hle --all-targets -- -D warnings` passed with 0 warnings - `cargo xtask policy` passed (`191 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2511:upstream-pr/2511'
git switch 'upstream-pr/2511'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2511'
git switch 'upstream-pr/2511'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2511'
git switch 'upstream-pr/2511'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2511'
git switch 'main'
git merge --squash 'upstream-pr/2511'
git switch 'main'
git merge --ff-only 'upstream-pr/2511'
git switch 'main'
git merge 'upstream-pr/2511'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2509
No description provided.