Repository navigation
process: park game threads that end the run until the host exits - #1013
Conversation
Under Wine before 11.2, gta6rt --run sometimes exited 0 although the game ended with 1 (run_tiny_game_exit_code in CI's Wine 9.0 job: 13 of 64 runs). end_run signalled the host and called ExitThread; the host's ExitProcess could then send SIGQUIT to that thread while it was exiting, Wine counted the thread out twice and the process ended with _exit(0). Upstream fixed it by blocking SIGQUIT during thread exit (4a9bc42a, wine-11.2). end_run now parks every caller while a run is in progress (the first one after recording the code and signalling), so no game thread is mid-exit when the host calls ExitProcess. This also fixes two threads calling exit at once: the second one called ExitProcess itself, sometimes before the first had stored its code, and ended the process with 0 on any OS. CI requires run_tiny_game_exit_code again.
|
Tested
AI-assisted. No game files. |
|
Tested 8b51490 with the native MSVC build (the part not run above): Windows 11 26200, MSVC 19.44, RelWithDebInfo. I applied it to
The machine has an Intel Arrow Lake iGPU and an RTX 5070 Ti, but this path doesn't touch the GPU. No game files. AI-assisted (Claude Code). |
quackottu
left a comment
There was a problem hiding this comment.
Tested 8b51490 on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass
ctest -C RelWithDebInfo: 100% tests passed, 0 tests failed out of 33- 39 test programs in the build pass with 0 validation errors
- Not run (they take an input file, not covered here): vk_overlapping_occlusion_test
d3d12_clear_testfails (R8G8B8A8_UNORM/SNORM 0.5 ties and a D16 clear byte differ from WARP) exactly as onmain4a36bb1 here, so not from this PR; #521 addresses it
Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.
Item: new RT item, @ayozetr's Wine exit-code finding (claim).
Under Wine before 11.2,
gta6rt --runsometimes exited 0 although the game ended with 1.run_tiny_game_exit_codefailed this way in 13 of the last 64 CI Wine runs (Ubuntu's Wine 9.0).Cause.
end_runsignalled the host and then calledExitThread. The host'sExitProcesscan send SIGQUIT to that thread while it is still exiting. Wine 9.0 doesn't block SIGQUIT there, so the thread counts itself out twice (exit_thread, thenabort_threadfromquit_handler), the thread count reaches 0 and Wine calls_exit(0)before the host'sexit(1). Upstream fixed this in 4a9bc42a ("ntdll: Add SIGQUIT to the blocked signals"), first in wine-11.2, so CI's Wine 9.0 and distro Wines older than 11.2 still have it.Change. While a run is in progress,
end_runparks every caller (Sleep(INFINITE)), the first one after recording the code and signalling the host, so no game thread is mid-exit when the host callsExitProcess. This also fixes a bug on every OS: when two game threads calledexitat once, the second one calledExitProcessitself, sometimes before the first had stored its code, and the process ended with 0. Calls after the run (during host shutdown) still end the process with the game's code, as before. CI requiresrun_tiny_game_exit_codeagain (reverts 734fe50).Not covered. Under Wine < 11.2, any other thread that happens to be exiting by itself at the moment the host calls
ExitProcesscan still turn the exit code into 0. That can't be fixed from the PE side without tracking every game thread;tiny_gamejoins its worker, so CI isn't affected.Tested on CachyOS, Ryzen 7 7700X iGPU (RDNA2, RADV, Mesa 26.3.1), Windows runtime cross-built with clang-cl + xwin (#888's setup). The native MSVC build wasn't run here; the change is plain Win32.
tiny_game -- wrong argsexit(1)at onceexit(1)at oncetiny_game -- hello 42tiny_game -- wrong argsFull ctest under Wine 11.22: the same 4 failures as main (the tests that compare with the host's D3D12:
root_sig_test,device_proxy,root_sig,d3d12_vulkan_device). The plain Linux build is unaffected (process.cppis Windows-only).#802 edits the comment lines just above the
winejob, so expect a small rebase conflict there.AI-assisted (Claude-Opus).