Skip to content

xgameruntime_gamesave: the enumeration and info callbacks run outside the save lock, so a callback may wait on an async save call - #8222

Open
tedin7 wants to merge 2 commits into
ItsNotRexed:mainfrom
tedin7:c2-gamesave-callbacks-outside-lock
Open

tedin7 wants to merge 2 commits into
ItsNotRexed:mainfrom
tedin7:c2-gamesave-callbacks-outside-lock

Conversation

@tedin7

@tedin7 tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

What

Snapshot save container and blob records under the mutex, then invoke callbacks after releasing it.

Why

A callback waiting for asynchronous save work otherwise deadlocks on the global save mutex. Enumeration results and order are preserved.

Tested

  • p2 Windows/Wine, xgameruntime_gamesave_test: origin/main timed out after 3000 ms; corrected version: 61 checks, 0 failures.
  • git diff --check and check_no_game_data.py. No GPU used.

AI-assisted.

@ItsNotRexed: an exe PR, as you asked.

Claim: #8047 (comment)

@MartinIndra02

Copy link
Copy Markdown

Independent build + test: PASS

AI-assisted (Claude Code). Windows 11 x64, MSVC 19.44.35220, Ninja RelWithDebInfo. GPU (not used): NVIDIA GeForce RTX 3080 driver 621.24 / 32.0.16.2124.

Head fb9b21ff9, merged locally with current main c70e673e1 (clean merge).

Test PR (merged) runtime/shims/xgameruntime_gamesave.cpp reverted to main
xgameruntime_gamesave_test.exe exit 0, 64 checks, 0 failures exit 2: FAIL callback quota wait timed out after 3000 ms (the callback that waits on an async save call deadlocks on g_mutex)

Code check: all four paths (save_container_info, save_enum_containers, save_enum_containers_by_name, enumerate_blobs) copy the records under g_mutex and call the title's callback after releasing it. The callback sees const char* into the local copies, so a callback that closes the provider or container while it runs doesn't leave dangling strings. No issues found.

Note: #8229 changes the same file (cancel → E_ABORT). Whichever merges second should be rebuilt.

@kristofbarany

Copy link
Copy Markdown

Tested fb9b21f merged onto main 6312c05 (clean merge) on NVIDIA GeForce RTX 4070, driver 621.24, native Windows 11 Pro 26300, MSVC 14.44.35207, Ninja RelWithDebInfo: pass.

  • xgameruntime_gamesave_test: passes.
  • The one build warning, C4996 std::filesystem::u8path in xgameruntime_gamesave_test.cpp, is also on main; this PR adds none.

No game data used. AI-assisted (Claude Code).

@comtek21516

Copy link
Copy Markdown

Tested fb9b21ff9 on main at 867d922f0, in one tree with #8163, #8271, #8050, #8221 (five clean merges; the changes do not depend on each other): pass.

For this change. xgameruntime_gamesave (xgameruntime_gamesave_test, with the new callback cases) passes natively and under Wine on the GPU machine.

Setup. Built with MSVC 14.52 (Visual Studio 18), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.1, Ninja RelWithDebInfo on Windows Server 2025 (no Vulkan driver there), then the same binaries run through scripts/run_wine_tests.py under wine-11.0 (WineHQ stable, xvfb-run) on a Quadro RTX 4000 (Turing), NVIDIA 615.71.09, Ubuntu 22.04.5, where the layer tests report device: Quadro RTX 4000.

passed failed skipped
native Windows, this tree 148 4 124
Wine on the GPU, main 867d922f0 210 12 54
Wine on the GPU, this tree 210 12 55

Under Wine the tree is test by test the same as main; the one extra skip is #8271's new d3d12_trace_file, which the Wine runner does not start (it is driven by Python). The four native failures are gameinput_host, d3d12_sparse_queue_family, vk_bindless_ps_tex and vk_bindless_ps_imgatomic, which fail the same way on main on that machine (#7452). The 12 under Wine are the same 12 as on main: host comparisons Wine cannot answer and three tests also reported failing on native NVIDIA (d3d12_xdxr_rt, d3d12_indirect_rt, d3d12_indirect_dispatch_count).

Because the five were built together, there is no per-PR negative control in this run: a regression would have shown as a difference from main, and there is none. No game files used. AI-assisted (Claude Code).

@Kerwinss

Copy link
Copy Markdown

Tested fb9b21f on Windows 11 Pro 10.0.26300, MSVC 14.51 (VS Build Tools 2026), Windows SDK 10.0.26100, NVIDIA GeForce RTX 4060 / 621.24, Khronos Vulkan headers via -DLEONIDA_VULKAN_HEADERS_FETCH=ON: pass, no regression.

Merged onto main 6312c05 (clean), full runtime build, ctest -C RelWithDebInfo -j4: 237/239. The only failures are the two main has on this GPU (d3d12_depth_resolve, fixed by #7985; d3d12_vulkan_device:6574).

xgameruntime_gamesave passes, including the callback-outside-the-lock case.

AI-assisted (Claude Code). No game files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants