fix(tests): end Windows test processes through libc before DLL detach #6986
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6986"
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 boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T01:48:54Z.
Windows CI times out single tests at 120 s after they have already finished (#6791). It's not specific to any test:
agc_driver_pm4_ring_invalid,agc_interpolant_mapping,guest_shader_linkand others hit it, and a re-run moves it to another test.The cause is the exit path. A test returning from
mainends throughexit->ExitProcess, which kills every other thread and only then runs the prx DLLs' static destructors atDLL_PROCESS_DETACH. Detached host threads are still alive at that point (the driver's async log thread,AsyncLog.hpp:196; libkernel's file-watch and alarm threads), and they die holding locks. A destructor that then flushes the async log, locks one of those mutexes or destroys a condition variable (winpthreads'pthread_cond_destroywaits without a timeout) never returns. Linux doesn't see it, becauseexitruns destructors while the threads are still alive. That's also why tests that already callLibcRunShutdownbefore returning (the approach in #6925) still hang: the detached threads outlive it, and DLL detach still runs after they're gone.This wraps
mainfor every test executable on MinGW (LINKER:--wrap=maininadd_test_executable,cmake/WindowsTestExit.cpp). Aftermainreturns, the wrapper runs the executable's own exit handlers and static destructors (_cexit), flushes the streams and ends the process withLibcTerminate_nid_no_patch(the path guest exit already uses: end-flush, thenTerminateProcess). The driver log is flushed while its thread is alive, and noDLL_PROCESS_DETACHwork runs after the threads are gone. The libc shutdown callbacks are not run, matching a plain return frommainon Linux. A test that doesn't loadlibc.prxreturns as before. Linux and macOS are unchanged.It replaces the per-test approach in #6925, which becomes redundant but harmless.
Validation: I don't have a Windows machine, so this PR's Windows CI is also its first compile. I'll repeat the full Windows run several times and compare the timeout count with main (about 5 timeouts in 11 runs on 10-16).
Refs #6791, #6925.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T01:59:32Z.
The current conventions check fails because the PR body is missing the template sections
What,TestedandChecklist. Please restore those headings and fill them in; the check reports all three as empty.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T02:11:42Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
CMakeLists.txtCMakeLists.txtCMakeLists.txtCMakeLists.txtCMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-17T02:23:34Z.
Windows run: i7-13700K, RTX 4080 (617.42) and Intel UHD 770 (101.6129), WinLibs GCC 15.2.0, Release. Tested #6986 (
ea33174d7) merged onto mainf643e61d9.guest_shader_link alone on the UHD 770, 15 runs, 60 s timeout
Full
ctest -j4 --timeout 300, 1351 tests: no timeouts on either GPU. Without this PR, guest_shader_link timed out on the UHD in our full runs.Failures that remain, all failing on plain main
f643e61d9too (checked by rerunning them there), so none come from this PR:agc_driver_gpu_map_on_fiber("started 1 host threads for its import instead of importing on the fiber's host stack"),guest_kqueue(0xc0000409)agc_driver_bindless_images,agc_driver_image_sint8,agc_driver_image_table,agc_driver_image_table_cache_bounds/_reuse(0xc0000409),agc_driver_sample_multisample_target("sample 1 of pixel (0, 0) does not hold the stored color")AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T03:14:37Z.
Thanks @johnmaia, that's very useful. The fiber import and
guest_kqueuefailures are being looked at against #6993 and #6599/#6173. For the UHD-only 0xc0000409 group (agc_driver_bindless_images,agc_driver_image_sint8,agc_driver_image_table,agc_driver_image_table_cache_bounds/_reuse), I couldn't find an existing issue. Could you open one with thectest --output-on-failureoutput for one of them on the UHD 770, plus the driver version and main commit? A debugger backtrace for the 0xc0000409 would help most, if you can get one.