XGameRuntime: a save read sees all of an update or none of it #2132
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2132
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2132"
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?
@dhillonjagdeep650-boop on GitHub · 2026-11-25 05:41 UTC · original
dhillonjagdeep650-boop:xgamesave-read-during-update→main· +42 −1 · 1 files · 1 commits · openXGameSaveReadBlobDataandXGameSaveReadBlobDataAsyncread a container's blobs without the lock thatXGameSaveSubmitUpdateholds while it replaces them one file at a time. A read that runs during an update can return some blobs from before the update and some from after it. It can also make the update fail: while the read has a blob open,MoveFileExWcannot replace that file, andapplyreturnsE_FAILwith part of the update written (the half-applied state of #324, reached without a disk error). Found by reading the code and reproduced with a unit test; not seen in a title.What is in it
crates/xcl/src/hle/xgameruntime/gamesave.rs:read_layouttakesSAVE_MUTATION, asapplyanddelete_containerdo (one line, plus the lock's comment).reads_during_an_update_see_all_of_it_or_none: one thread reads two blobs in a loop while another rewrites both in 30 updates. It counts failed updates, reads whose two blobs come from different updates, and failed reads; all three must be 0.Rebased on
maine1d84b7as8be0c36:a18c180conflicted withmainafter #2165 (both add a test at the same place ingamesave.rs). Nothing in the fix changed; the test now sits after #2165's.Tested
8be0c36unless said otherwise.cargo test --locked -p xcl --lib -- gamesave: 12 passed, 0 failed.read_layoutline (on the rebased tree beforemaine1d84b7,81615a0): fails 5 of 5 runs (failed updates / mixed reads / failed reads per run: 21 / 68 / 0, 22 / 17 / 0, 15 / 6 / 0, 9 / 51 / 0, 16 / 47 / 0). With it: passes 5 of 5.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=1(LOCALAPPDATApointed at an empty folder, noXCL_*variable): 1424 passed, 0 failed, 46 ignored, no driver event in Windows' log. SKIPPED (29 lines): 21no wave64cases, 3 per-lane forms refused as unsupported (V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows),pso_measurement_compiles_an_exact_synthetic_record(needs Windows Developer Mode), and the three debug-layer cases (nod3d12SDKLayers.dll).a18c180: @luckyteagirl ran the gamesave tests on AMD (RX 6800M), 11 passed, and the new test 20 of 20 times; @DavidM1911 the lib tests on an RTX 3060 Ti.Regression run
scripts/smoke.ps1 -Game <retail title> -Seconds 180with scripted A presses at 16, 20, 24, 28, 32 and 36 s (XCL_PRESS_A_AT) and nothing else, each run with an empty data root and its own copy of the same DXIL cache, nobody at the controller.mainfirst, then this PR, 10 minutes apart:Both reach the same screen and present to the end. No file was written under
gamesavein either run, so these runs do not show that the title reaches the changed code. (A first run of the PR head was discarded: a real controller press at 98 s took it further thanmain's run.)The earlier 60 s pair of
6020a33/a18c180had uncontrolled input; it is replaced by this pair.Not tested
8be0c36(AMD only for the gamesave tests ona18c180), wave64 hardware, the test suite in release.XGameSaveEnumerateBlobInfo,XGameSaveEnumerateContainerInfo,XGameSaveGetRemainingQuota) still run without the lock. They open no blob, so they cannot block an update, but they can list a container partway through one. Not changed here.apply; neither locksread_layout.AI use
8be0c36.🤖 Generated with Claude Code
@luckyteagirl on GitHub · 2026-11-25 06:22 UTC · original
Independent native Windows check of exact PR head
a18c180ce39a1b407e964e541be7c68a8bf94f50.Tested
30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. These are save-file tests; the GPU was not used.cargo test --locked -p xcl --lib -j 2 gamesave -- --test-threads=1 --show-output: 11 passed, 0 failed, 0 ignored, includingreads_during_an_update_see_all_of_it_or_none.cargo testprocess 20 times, sequentially, with--test-threads=1: 20/20 runs passed, each reporting 1 passed, 0 failed and noSKIPPEDline. The test performs its 30 update/read rounds each time, so this is 600 rounds across the repeated runs.This checks the race regression and neighboring GameSave tests on this Windows machine. I did not run a pre-fix negative control here, the full workspace suite, or a retail title save operation. The short title startup available on this machine does not reach GameSave calls. No game data was used or uploaded.
AI-assisted testing and report drafting with OpenAI Codex (GPT-6); I checked the exact revision, per-run log, and aggregate counts before posting.
@DavidM1911 on GitHub · 2026-11-25 06:32 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@raylitebull on GitHub · 2026-11-25 10:46 UTC · original
Code review on
a18c180:SAVE_MUTATIONinsideread_layout(crates/xcl/src/hle/xgameruntime/gamesave.rs) cleanly prevents concurrentapply()updates from producing torn multi-blob reads, verified byreads_during_an_update_see_all_of_it_or_none.#2165(1028ba5), which locksSAVE_MUTATIONaroundeach_blobenumeration.Remaining before merge:
Build and testfinishing green plus dual-vendor verification ona18c180.@DavidM1911 on GitHub · 2026-11-26 07:30 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: 1 failure under parallel scheduling; clean on--test-threads=1rerun (1310 passed, 0 failed, 27 ignored, 94s). Intermittent single-test flake — tracked in #1978.Thanks!
— Devin
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.