Skip to content

TEST-899: loader_tls's purge test uses suspended, console-less children (fixes the ctest + Wine hang) - #4091

Open
ray3242 wants to merge 1 commit into
ItsNotRexed:mainfrom
ray3242:devin/1795389726-loader-tls-suspended-child
Open

ray3242 wants to merge 1 commit into
ItsNotRexed:mainfrom
ray3242:devin/1795389726-loader-tls-suspended-child

Conversation

@ray3242

@ray3242 ray3242 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST-899 (claim, from ddm-j's finding)

What and why

loader_tls intermittently hangs under ctest + Wine after printing loader_tls_test: OK (69 checks), until ctest's timeout. test_purge_ownership_scoping got its dead and live owner PIDs from cmd.exe /c exit 0 and cmd.exe /c timeout /t 30 children started with CREATE_NO_WINDOW. Under Wine every console child gets a headless conhost.exe --server ... --headless, which inherits the runner's Unix stdout/stderr. In a hung run, the test exe and both cmd.exe children were gone, and the only process (besides wineserver) still holding ctest's output pipe was that run's conhost. Reparented to init, it stayed alive after the run, so ctest never saw EOF.

The children are now copies of the test executable started with CREATE_SUSPENDED | DETACHED_PROCESS. They never run and have no console, so no conhost is started, and they still give one dead PID (terminated and waited) and one live PID for the two ownership checks. Test-only change; the purge logic in pe_loader.cpp is untouched.

Tested

Linux VM (no GPU needed), Wine 11.0, clang-cl/xwin cross build of runtime/ (RelWithDebInfo), ctest -R '^loader_tls$' run back to back:

  • main (aa2988c): 2 hangs in 19 runs (ctest Timeout). Each hang left a headless conhost running; in the one I inspected, it held ctest's output pipe.
  • this branch: 40/40 passed, with no new conhost processes left behind.
  • Direct run: all 5 purge checks pass and the suite reports OK (69 checks).

Native Windows: MKmajster ran e9fe3485 on Windows 11 24H2, MSVC 19.44: ctest -R ^loader_tls$ --repeat until-fail:30 passed 30/30 with no hangs. Maraco91 also passed e9fe3485 on Windows 11 26200, MSVC 19.42.

Wine, by the finder: ddm-j passed e9fe3485 under Wine 11.21 on Fedora 45, on a Radeon 610M (RADV) and an RTX 4070 Ti: 10/10 on both GPUs with no conhost left behind, where main timed out in 8 of 10 run_wine_tests-style runs and 7 of 10 ctest runs.

AI-assisted (Devin).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

test_purge_ownership_scoping spawned cmd.exe with CREATE_NO_WINDOW for its
dead and live owner PIDs. Under Wine each console child starts a headless
conhost.exe, which inherits the runner's output pipe and can outlive a
terminated child, so ctest waits on the pipe after the test printed OK.

The children are now copies of the test executable started with
CREATE_SUSPENDED | DETACHED_PROCESS: they never run, have no console, and
still give one dead PID (terminated and waited) and one live PID.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@MKmajster

Copy link
Copy Markdown

Tested e9fe348 on native Windows (the description covers Wine): Windows 11 24H2 (26100), MSVC 19.44 RelWithDebInfo + Ninja. Pass: the suspended, detached children still give the two ownership checks what they need there.

  • ctest -R ^loader_tls$ --repeat until-fail:30: 30/30 passed, no hang.
  • No loader_tls_test process left behind afterwards. The live child is cleaned up, so the suspended copy doesn't outlive the run on Windows either.

No game files. AI-assisted (Claude).

@Maraco91

Copy link
Copy Markdown

Tested e9fe348 on Windows 11 26200, MSVC 19.42 (VS 2022 Build Tools), Windows SDK 10.0.28000.0: pass, as the no-regression check on native Windows

  • scripts\build_runtime.ps1: builds clean.
  • ctest -R loader_tls: passes (0.23 s).
  • No loader_tls_test.exe process is left afterwards, so the suspended "live" child is ended by its destructor.

What this does not cover: the hang itself. It needs ctest under Wine, which I don't have, so the 19-run comparison in the description is not repeated here.

Reading the change: CREATE_SUSPENDED | DETACHED_PROCESS on a copy of the test executable gives a PID without running any code and without a console, and end() terminates and waits before closing the handle, so the "dead" PID is really gone when the purge checks run. GetModuleFileNameW is checked for both failure and truncation.

AI-assisted (Claude Code); no game files, no GPU involved in this test.

@YaBulochka

Copy link
Copy Markdown
Contributor

Independent data point from a different Wine: on Arch Linux with wine-11.22, the Windows build of main (b8259d91, i.e. without this fix) shows no hang.

  • scripts/run_wine_tests.py over the full 123-test ctest list: 89 passed, 9 failed, 25 skipped, and all six --require tests pass, loader_tls included.
  • loader_tls_test.exe fixtures/RelWithDebInfo/tiny_tls.dll run directly 30 times in a row under the same prefix: 30/30 exit 0, OK (58 checks) each, none slower than a couple of seconds.
  • The 9 failures are the non-required present/DXGI/XDXR set (device_proxy, d3d12_xs_root_signature, xdxr_build, vk_presenter_sync, d3d12_xdxr_rt, d3d12_present, xbox_present, dxgi_swapchain, d3d12_compute), none loader-related.

So the hang looks specific to the older Wine the CI uses (the Ubuntu and winehq-stable images), not to the purge path in general; this box cannot independently confirm the fix, only that it does not regress Wine 11.22. Worth stating in the PR what Wine version the hang was measured on, if that is not already in the thread.

@ray3242

ray3242 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@YaBulochka thanks for running it. One problem, though: b8259d91 (the #2765 merge) is 2541 commits behind main and predates #2070 (00f9ebd), which added test_purge_ownership_scoping and its cmd.exe children. So the build you ran doesn't contain the code that hangs. That fits your OK (58 checks): on main the test prints OK (69 checks), and the extra 11 checks come from the purge test.

Where the hang was measured:

The hang only shows under ctest, because it waits for EOF on the output pipe that the leftover conhost holds. Running the test directly or through a shell pipe exits cleanly, so the 30 direct runs wouldn't catch it either way.

If you can, ctest --test-dir <build> -R ^loader_tls$ --repeat until-fail:20 --timeout 60 on current main and then on e9fe348 under 11.22 would show whether 11.22 still hangs.

AI-assisted (Devin).

@ddm-j

ddm-j commented Nov 23, 2026

Copy link
Copy Markdown

Tested e9fe348 under Wine 11.21 (Fedora 45) on AMD Radeon 610M iGPU (RDNA2, RADV Mesa 26.2.6) and NVIDIA RTX 4070 Ti (615.78.08), where the hang reproduces at a high rate on main: pass, the hang is gone.

loader_tls, 30 s cap per run main aa2988c this PR e9fe348
Launched the way scripts/run_wine_tests.py does (subprocess.run, stdout piped, stderr to stdout), the path CI's wine job uses with --require loader_tls 8 of 10 timed out (RADV), each after OK (69 checks) 10/10 pass on RADV, 10/10 on the 4070
ctest -R ^loader_tls$ 7 of 10 timed out at #2070's merge 00f9ebd; times out on both GPUs on main 10/10 pass on each GPU
Headless conhost.exe processes in the prefix, before and after the 10 ctest runs — 4 before, 4 after on each GPU (none left behind)

Run directly, all five purge checks still pass ("deleted the clone whose owner process is gone", "skipped the clone another handle holds open", "skipped the clone whose owner process is still alive", and the two setup checks), with loader_tls_test: OK (69 checks).

On the thread above: this machine reproduces the hang on current main, through the same launch method run_wine_tests.py uses. So once the runtime workflow runs on main again, CI's required loader_tls should fail intermittently there until this lands.

AI-assisted (Claude Code); counts copied from the run logs.

@ray3242

ray3242 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@MKmajster @Maraco91 @ddm-j — thank you for the three independent confirmations on e9fe3485; I'd missed acknowledging them earlier.

  • Native Windows 11 24H2 / MSVC 19.44 (MKmajster) and Windows 11 26200 / MSVC 19.42 (Maraco91): the suspended, detached children still satisfy both ownership checks, and ctest -R loader_tls passes.
  • ddm-j: the hang reproduces at a high rate on main under Wine 11.21 on both RDNA2 (RX 610M / RADV 26.2.6) and NVIDIA RTX 4070 Ti / 615.78.08, and is gone with the PR — that negative control is the strongest evidence here.

Together with my GTX 1060 / 582.78 Windows run, the fix now has native Windows, Wine, NVIDIA and AMD coverage. No action needed from you. AI-assisted (OpenCode); no game data.

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