HLE XGameSave: tolerate locked old or unfinished version cleanup #3104

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

@⁠fuzeofficlal on GitHub · 2026-11-26 08:12 UTC · original
fuzeofficlal:fix/hle-xgamesave-tolerate-locked-cleanup → main · +85 −5 · 1 files · 1 commits · open

Summary

  • In crates/victory-hle/src/modules/xgamesave.rs (current), treat std::fs::remove_dir_all failures when cleaning stale *.new staging folders or older v<old> committed versions as non-fatal (tracing::warn! and continue) instead of aborting container reads and blocking subsequent updates (e.g., when Windows AV/backup scanners temporarily hold a file in an older version folder without delete sharing).
  • Critical I/O errors that affect reading or committing the active version (read_dir, load, commit staging/rename, or missing readable manifests) continue to propagate unchanged.
  • Added two Windows-native regression tests using OpenOptionsExt::share_mode(0) verifying that reads, subsequent updates, and post-unlock cleanup all succeed when an old version or stale .new directory is locked.

(Issue pattern originally noted in fxceless/victory-fork 6a42ed27; implemented cleanly against main with Windows-native locked-file regression tests.)

Verification

  • cargo test -p victory-hle --locked -- modules::xgamesave::: 13 passed, 0 failed.
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean.
  • cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings: clean.
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 08:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/3104) `fuzeofficlal:fix/hle-xgamesave-tolerate-locked-cleanup` → `main` · +85 −5 · 1 files · 1 commits · open ## Summary - In `crates/victory-hle/src/modules/xgamesave.rs` (`current`), treat `std::fs::remove_dir_all` failures when cleaning stale `*.new` staging folders or older `v<old>` committed versions as non-fatal (`tracing::warn!` and continue) instead of aborting container reads and blocking subsequent updates (e.g., when Windows AV/backup scanners temporarily hold a file in an older version folder without delete sharing). - Critical I/O errors that affect reading or committing the active version (`read_dir`, `load`, `commit` staging/rename, or missing readable manifests) continue to propagate unchanged. - Added two Windows-native regression tests using `OpenOptionsExt::share_mode(0)` verifying that reads, subsequent updates, and post-unlock cleanup all succeed when an old version or stale `.new` directory is locked. (Issue pattern originally noted in `fxceless/victory-fork` `6a42ed27`; implemented cleanly against `main` with Windows-native locked-file regression tests.) ## Verification - `cargo test -p victory-hle --locked -- modules::xgamesave::`: 13 passed, 0 failed. - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: clean. - `cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings`: clean. - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:24:29 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 08:24 UTC · original

Automated triage for the maintainers.

Merge candidate. In crates/victory-hle/src/modules/xgamesave.rs, current now logs and continues when remove_dir_all fails on a leftover *.new staging folder or an older v<N> version. Before, a file held open without delete sharing (a scanner, a backup tool) made every read and update of that container fail. I checked that the cleanup is the only thing relaxed:

  • read_dir, load, commit and the commit rename still propagate their errors.
  • A partly removed older version is never chosen: the newest readable version is picked first, and older folders are only cleanup targets.

The two Windows tests lock a file with share_mode(0) and check that reads and updates still work, and that cleanup finishes once the lock is gone. CI (check, windows-latest) passes.

A note: a locked leftover named v<highest+1>.new still fails the next update. commit removes that exact folder first and propagates the error, as on main. That is the usual crash leftover, so the test with v99.new steps around it. It is not a regression, but a follow-up could commit to a fresh name in that case.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 08:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/3104#issuecomment-7186561134) <!-- victory-triage v1 head=c4509390cfc9bb03a83eee135cb18913e96158e9 verdict=merge-candidate at=2026-11-26T08:18:11Z --> Automated triage for the maintainers. **Merge candidate.** In `crates/victory-hle/src/modules/xgamesave.rs`, `current` now logs and continues when `remove_dir_all` fails on a leftover `*.new` staging folder or an older `v<N>` version. Before, a file held open without delete sharing (a scanner, a backup tool) made every read and update of that container fail. I checked that the cleanup is the only thing relaxed: - `read_dir`, `load`, `commit` and the commit rename still propagate their errors. - A partly removed older version is never chosen: the newest readable version is picked first, and older folders are only cleanup targets. The two Windows tests lock a file with `share_mode(0)` and check that reads and updates still work, and that cleanup finishes once the lock is gone. CI (`check`, windows-latest) passes. A note: a locked leftover named `v<highest+1>.new` still fails the next update. `commit` removes that exact folder first and propagates the error, as on main. That is the usual crash leftover, so the test with `v99.new` steps around it. It is not a regression, but a follow-up could commit to a fresh name in that case. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 08:28 UTC · original

Independent Windows CPU verification of PR #3104 at c4509390cf (single commit, parent 63bcca43c6 = main). Claim: #1633 . Windows 11 x64, no GPU, no gamepad, cargo test --locked -j 4 -p victory-hle --lib xgamesave, isolated tempdirs only, synthetic data only.

  • Head: 13/13 pass, including the two new tests (locked old version, locked unfinished .new version).
  • Parent: 11/11 pass (the two new tests do not exist there).
  • Control: head tests with only the two cleanup hunks reverted to remove_dir_all(...)? fail both new tests with Windows error 32 (sharing violation), so the tests do exercise the change.
  • Extra scratch test (not committed, not proposed): zero-share directory handles on an old v1 and a v50.new staging dir. Repeated reads returned the newer committed version, update to v3 succeeded, both locked dirs were left in place, and after release the next read removed both. With a zero-share lock on the active version's manifest: read and update both returned the same error (NO_ACCESS), v3 was kept, no v4 was created; after release, read and update worked normally.

Not checked: source review, other platforms, clippy. Test report only; no source changes and no PR from me.

AI use: Claude Code (Claude Sonnet 5.5) ran the checks, coordinated by Codex (gpt-6.2-sol).

**@⁠oni-swr** on GitHub · 2026-11-26 08:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/3104#issuecomment-7186636964) Independent Windows CPU verification of PR #3104 at c4509390cfc9bb03a83eee135cb18913e96158e9 (single commit, parent 63bcca43c6a00a758510398fa43096ce7e4f7df0 = main). Claim: https://git.gtahub.st/github/Marvisak--VIctory/issues/1633 . Windows 11 x64, no GPU, no gamepad, `cargo test --locked -j 4 -p victory-hle --lib xgamesave`, isolated tempdirs only, synthetic data only. - Head: 13/13 pass, including the two new tests (locked old version, locked unfinished `.new` version). - Parent: 11/11 pass (the two new tests do not exist there). - Control: head tests with only the two cleanup hunks reverted to `remove_dir_all(...)?` fail both new tests with Windows error 32 (sharing violation), so the tests do exercise the change. - Extra scratch test (not committed, not proposed): zero-share directory handles on an old `v1` and a `v50.new` staging dir. Repeated reads returned the newer committed version, update to `v3` succeeded, both locked dirs were left in place, and after release the next read removed both. With a zero-share lock on the active version's manifest: read and update both returned the same error (NO_ACCESS), `v3` was kept, no `v4` was created; after release, read and update worked normally. Not checked: source review, other platforms, clippy. Test report only; no source changes and no PR from me. AI use: Claude Code (Claude Sonnet 5.5) ran the checks, coordinated by Codex (gpt-6.2-sol).
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 08:30 UTC · original · approved these changes

Verified against origin/main (63bcca4):

  • cargo test -p victory-hle --lib modules::xgamesave:: -- --test-threads=1: 13/13 passed (including a_locked_old_version_does_not_block_reads_or_updates and a_locked_unfinished_version_does_not_block_reads_or_updates).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly tolerates locked old or unfinished version directories during XGameSave cleanup instead of failing reads/updates.

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

**@⁠Dukestar69** on GitHub · 2026-11-26 08:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/3104#pullrequestreview-6070721410) · **approved these changes** Verified against `origin/main` (`63bcca4`): - `cargo test -p victory-hle --lib modules::xgamesave:: -- --test-threads=1`: 13/13 passed (including `a_locked_old_version_does_not_block_reads_or_updates` and `a_locked_unfinished_version_does_not_block_reads_or_updates`). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly tolerates locked old or unfinished version directories during XGameSave cleanup instead of failing reads/updates. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 20:01 UTC · original

NVIDIA full-suite run, to go with the reports above by Dukestar69, oni-swr, since none of them names a GPU run. Tested exact head c450939 (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: 868 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: a_locked_old_version_does_not_block_reads_or_updates, a_locked_unfinished_version_does_not_block_reads_or_updates.
  • --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-26 20:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/3104#issuecomment-7202209127) NVIDIA full-suite run, to go with the reports above by Dukestar69, oni-swr, since none of them names a GPU run. Tested exact head `c450939` (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`: **868 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `a_locked_old_version_does_not_block_reads_or_updates`, `a_locked_unfinished_version_does_not_block_reads_or_updates`. - `--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.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 20:32 UTC · original

There is one remaining Windows retry case on c450939 plus the current #3329 head 80e854a. A locked v99.new lets the next write proceed because it uses v2.new. If the locked directory is v2.new itself, the read succeeds but the submit returns 0x80830002. The same collision with v1.new keeps a legacy save in the old layout even after its last unreadable blob is released.

Candidate 6e9fd60 leaves the occupied staging directory for the next cleanup and writes into the first free version. A normal update commits to v3 and retains the untouched blob. A legacy save migrates to v2 as soon as its original files can be read, with both blobs and the display name intact. In both cases, a later read removes the stale stage after its handle is released.

Both focused regressions fail before the fix. With it, all 15 save tests and all 156 HLE tests pass on Windows, including the crash points. Strict HLE Clippy with and without diagnostics and the asset policy check pass. The tests use synthetic temporary saves.

@⁠fuzeofficlal, could you review the version selection against your cleanup change? The commit has both exact PR heads as parents. If you fold the change into your branch, please keep the Git author or use Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 20:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/3104#issuecomment-7202801332) There is one remaining Windows retry case on `c450939` plus the current #3329 head `80e854a`. A locked `v99.new` lets the next write proceed because it uses `v2.new`. If the locked directory is `v2.new` itself, the read succeeds but the submit returns `0x80830002`. The same collision with `v1.new` keeps a legacy save in the old layout even after its last unreadable blob is released. [Candidate `6e9fd60`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/6e9fd600ba9a9e3952c7f3e113543c78dfae4a94) leaves the occupied staging directory for the next cleanup and writes into the first free version. A normal update commits to `v3` and retains the untouched blob. A legacy save migrates to `v2` as soon as its original files can be read, with both blobs and the display name intact. In both cases, a later read removes the stale stage after its handle is released. Both focused regressions fail before the fix. With it, all 15 save tests and all 156 HLE tests pass on Windows, including the crash points. Strict HLE Clippy with and without diagnostics and the asset policy check pass. The tests use synthetic temporary saves. @⁠fuzeofficlal, could you review the version selection against your cleanup change? The commit has both exact PR heads as parents. If you fold the change into your branch, please keep the Git author or use `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
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/3104/head:github-bot/gh-3104'
git switch 'github-bot/gh-3104'

Merge

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