XGameRuntime: blob_enumeration_sees_one_submitted_update fails on Windows NTFS (DirEntry::metadata cache) #2411
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 ivall/xcl. Originally posted by Ritolino on 2026-11-25T18:23:07Z.
hle::xgameruntime::gamesave::tests::blob_enumeration_sees_one_submitted_update (added in #2165) fails on Windows 11 (NTFS), both under .\scripts\test.ps1 (--test-threads=4) and when run standalone:
thread 'hle::xgameruntime::gamesave::tests::blob_enumeration_sees_one_submitted_update' panicked at crates\xcl\src\hle\xgameruntime\gamesave.rs:1184:9: assertion left == right failed: 2 of 31 enumerations mixed submitted updatesRoot cause
Both pply and each_blob hold SAVE_MUTATION, so lobs_of does not run concurrently with MoveFileExW. However, lobs_of (crates\xcl\src\hle\xgameruntime\gamesave.rs:121) reads file sizes via DirEntry::metadata(), which on Windows returns the size cached in the NTFS directory index entry (FindNextFileW), which can lag behind an atomic MoveFileExW replacement across adjacent files.
Using std::fs::metadata(e.path()) (or File::metadata) instead of DirEntry::metadata() should bypass the directory-entry cache, though crates/xcl/src changes require xcl-smoke runs on a real title.
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T21:10:22Z.
Claiming this issue: reproducing and fixing the Windows NTFS
DirEntry::metadata()cache race inhle::xgameruntime::gamesave::blobs_of, with regression verification.AI use: Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by vibryxcx on 2026-11-27T02:46:26Z.
A second failure mode of the same test, separate from the
DirEntry::metadata()cache race above. Noting it here because @oni-swr is on this test, so one fix can cover both.On an RX 6800 machine (Windows 11 Pro 26200, NTFS,
amd-devbf7c82ee, debug), the test run alone failed 1 of 3, then 2 of 5. It failed earlier than the mixed-enumeration assert, atgamesave.rs:1179, in the writer:apply(...) == S_OK, left-2147467259(E_FAIL). A temporaryeprintln!inwrite_atomic(local only, removed) showed the failing call:MoveFileExW(tmp, dest, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH)inreplace_filereturnedAccess is denied. (os error 5), for example on…\slot\b\blob11and…\slot\b\blob04under%TEMP%.each_blobholdsSAVE_MUTATION, so the test's reader is not the holder. Something outside XCL had the destination open for a moment, most likely Defender scanning a file that was just written.replace_filemakes one attempt, so a single save update fails as a whole, and a title's save could fail the same way on a user's machine. A short bounded retry onERROR_ACCESS_DENIED/ERROR_SHARING_VIOLATIONinreplace_filewould cover it. Themetadata()change alone would not.Also posted with the suite run in #42. AI use: Claude Code (Claude Opus 5.5) ran the tests, added and removed the probe, and wrote this comment.
Update: this test also leaks its reader thread when it fails, and that is what makes the
gamesavemodule abort with0xc0000005. Onbf7c82ee, module run on its own (cargo test -p xcl --lib -- --test-threads=1 xgameruntime::gamesave::tests): 6 of 20 runs aborted, and in exactly those 6 this test's writer assert (gamesave.rs:1179) fired. Skipping this test gave 0 of 20. The other 10 tests alone, 15 runs each, never abort.The cause:
address = &mut container as *mut Containergoes to a detached reader thread. When an assert panics in the main body, the test unwinds and dropscontainerwithout settingdoneor joiningreader. The reader keeps enumerating the freed stack slot until a later test crashes. So whichever fix lands here (#2521 for the size cache, a retry for #2941), the test should also stop and join the reader on every path, for example with a guard that setsdoneand joins inDrop, or withstd::thread::scope. Otherwise any future failure of this test takes the rest of the module down with it. Details in #42.Correction (my "cause found" above was wrong about the mechanism). I wrote the fix I suggested: the reader runs in
std::thread::scope, with a guard that setsdoneon drop, so it is always stopped and joined beforecontainergoes away. I tested it onmainf9a0cb80, gamesave module alone, 20 runs each: the module aborted with0xc0000005in 11 of 20 runs without the fix and 11 of 20 with it. In an aborting run with the fix,blob_enumeration_sees_one_submitted_updateitself fails cleanly (FAILED), and the next test (case_insensitive_blob_and_container_matching_on_ntfs) then aborts. Skippingblob_enumeration_sees_one_submitted_updatestill gives 0 of 10 aborts onmain. So a failing run of that test is what is followed by the abort, but the detached reader is not the mechanism: something else that the failed test leaves behind takes the next test down. I do not know what yet. My earlier "writer assert fired in exactly those 6" count was also unreliable: when the process aborts, cargo never prints the failure section, so that count could not see failures in aborting runs.