HLE XGameSave: tolerate locked old or unfinished version cleanup #3102
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3104"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T08:12:04Z.
Summary
crates/victory-hle/src/modules/xgamesave.rs(current), treatstd::fs::remove_dir_allfailures when cleaning stale*.newstaging folders or olderv<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).read_dir,load,commitstaging/rename, or missing readable manifests) continue to propagate unchanged.OpenOptionsExt::share_mode(0)verifying that reads, subsequent updates, and post-unlock cleanup all succeed when an old version or stale.newdirectory is locked.(Issue pattern originally noted in
fxceless/victory-fork6a42ed27; implemented cleanly againstmainwith 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.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T08:30:21Z.
Review: APPROVED
Verified against
origin/main(63bcca4):cargo test -p victory-hle --lib modules::xgamesave:: -- --test-threads=1: 13/13 passed (includinga_locked_old_version_does_not_block_reads_or_updatesanda_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).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T08:24:43Z.
Automated triage for the maintainers.
Merge candidate. In
crates/victory-hle/src/modules/xgamesave.rs,currentnow logs and continues whenremove_dir_allfails on a leftover*.newstaging folder or an olderv<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,commitand the commit rename still propagate their errors.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>.newstill fails the next update.commitremoves that exact folder first and propagates the error, as on main. That is the usual crash leftover, so the test withv99.newsteps around it. It is not a regression, but a follow-up could commit to a fresh name in that case.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T08:28:28Z.
Independent Windows CPU verification of PR #3104 at
c4509390cf(single commit, parent63bcca43c6= main). Claim: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7186472185 . Windows 11 x64, no GPU, no gamepad,cargo test --locked -j 4 -p victory-hle --lib xgamesave, isolated tempdirs only, synthetic data only..newversion).remove_dir_all(...)?fail both new tests with Windows error 32 (sharing violation), so the tests do exercise the change.v1and av50.newstaging dir. Repeated reads returned the newer committed version, update tov3succeeded, 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),v3was kept, nov4was 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).
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T20:01:17Z.
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 base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo 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.a_locked_old_version_does_not_block_reads_or_updates,a_locked_unfinished_version_does_not_block_reads_or_updates.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#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_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T20:32:20Z.
The revised follow-up supersedes the candidate below and includes the stale-write fix.
There is one remaining Windows retry case on
c450939plus the current #3329 head80e854a. A lockedv99.newlets the next write proceed because it usesv2.new. If the locked directory isv2.newitself, the read succeeds but the submit returns0x80830002. The same collision withv1.newkeeps a legacy save in the old layout even after its last unreadable blob is released.Candidate
6e9fd60leaves the occupied staging directory for the next cleanup and writes into the first free version. A normal update commits tov3and retains the untouched blob. A legacy save migrates tov2as 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]>.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T21:16:16Z.
@andrewpozdnakov7-jpg Thanks for putting together the combined test and version-advancement branch (
6e9fd600) and asking for a review!Advancing past a locked
v<N>.newstaging directory makes sense as a separate follow-up once #3104 and #3329 land (I'd like to keep #3104 strictly scoped to best-effort cleanup so it stays simple and review-ready), though there is one subtle data-loss interaction in6e9fd600to fix before taking that approach:v<N>incommit()turnssubmit()'s stale snapshot into silent save loss:#3329head80e854athat6e9fd600merges,old_moved(root, &self.name)only checkedroot.join(file_name(name)), whereasused_bytes(root)->containers(root)->migrate()matches legacy folders viadecode()(e.g. a%53lotdirectory or a case-differing folder on Windows).v<N>appears) betweensubmit()readingcurrentand callingcommit(), targetingv1directly letsrename("v1.new", "v1")fail safely against the populatedv1directory. With the probe loop in6e9fd600,if !version.try_exists()?skips past the newly committedv1, commits the partialUpdateasv2, returnsS_OK, and lets the nextcurrent()deletev1— losing the untouched blobs and display name.v<N>.new(ifv<N>itself appeared sincecurrent()was read, fail or re-readcurrentrather than skipping it), and ensure any legacy migration for the target container finishes beforesubmit()takes its snapshot.v<N>.newtriggersAlreadyExistsincreate_dir(&staged)and persists acrosscurrent()'sremove_dir_all, permanently skipping that version number and logging on every read.version.try_exists()?returnsOk(false)for a dangling symlink, deferring the collision torename.checked_add(1)overflow checks (submit()andcommit()), cleanup of a skippedv<N>.newonce unlocked, andcurrent()/current_named()selection after a skip all look solid.So keeping #3104 focused on cleanup and landing the
v<N>.new-only skip (paired with pre-snapshot migration) in a follow-up PR seems like the cleanest path.Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T21:42:02Z.
Your stale-snapshot review found a real flaw in my first candidate. With the old selection loop, the new test starts with a committed
v1containing a display name and two blobs, then callscommitwith a stale version number and a partial update. It reports success atv2. A plain file atv2.newalso let an update advance when it should have reported the collision.Revised follow-up
c82ac66supersedes6e9fd60. It uses Creaa's exact-name pre-snapshot migration fromffa792dand this PR'sc450939. It advances only past an occupied staging directory. If the committed name already exists, the stale commit refuses and the existing display and both blobs remain readable. A plain file at the staging name stays intact and the same update succeeds at the original version after the file is cleared. The locked staging-directory tests still pass.Windows HLE reported 159 passed, including all 18 save tests. Strict HLE Clippy in both configurations and the asset policy check passed. This is a separate follow-up for when #3104 and #3329 have landed. If you use the follow-up or its tests, please keep the Git author or use
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.