Windows: guest _Exit hangs in FlipQueue's destructor because ExitProcess still runs module detach routines #2579

Closed
opened 2026-10-10 06:50:31 +00:00 by AlxcBTW · 0 comments
AlxcBTW commented 2026-10-10 06:50:31 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-10T06:50:31Z.


On Windows a guest _Exit or _exit can hang instead of ending the process. Homebrew UI Lab (PPSA99050) calls _Exit(EXIT_FAILURE) from ps5-opengl's retirement fail-stop and then stays alive. gdb on the hung process shows one thread in std::_Sp_counted_ptr_inplace<FlipQueue>::_M_dispose (libSceVideoOut.prx), then std::thread::join, then WaitForMultipleObjects.

Cause

On Windows std::_Exit ends in ExitProcess. That still runs every module's DLL_PROCESS_DETACH and its TLS and FLS callbacks, after the other threads have been terminated. FlipQueue's destructor then joins a thread that is already gone and waits forever. POSIX _exit runs no atexit handlers, stream flushes or module destructors.

Fix

AlxcBTW:fix/windows-immediate-exit (2feef9e7, on main c963432d). Full CI, with the change merged into main c72d5ce1, passes on Linux, macOS and Windows. I can't open it as a PR while intake is limited, so it's here if a collaborator wants to cherry-pick it.

_Exit (libc) and _exit (libkernel) now end the process through LibcTerminate_nid_no_patch. That calls TerminateProcess on Windows and std::_Exit everywhere else.

Tested

Windows 11, WinLibs GCC 15.2.0 r7.

  • guest_immediate_exit now also registers an FLS callback that would end the process with 4. It exits with 4 without the change and with 0 with it. ctest -R "kill|exit|process|shutdown|atexit|libc|kernel": 19/19.
  • UI Lab: before the change the process stayed alive after submission retirement failed. With it, the process exits with 1 (EXIT_FAILURE).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5788929419 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2579). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-10T06:50:31Z. --- On Windows a guest `_Exit` or `_exit` can hang instead of ending the process. Homebrew UI Lab (PPSA99050) calls `_Exit(EXIT_FAILURE)` from ps5-opengl's retirement fail-stop and then stays alive. gdb on the hung process shows one thread in `std::_Sp_counted_ptr_inplace<FlipQueue>::_M_dispose` (`libSceVideoOut.prx`), then `std::thread::join`, then `WaitForMultipleObjects`. ### Cause On Windows `std::_Exit` ends in `ExitProcess`. That still runs every module's `DLL_PROCESS_DETACH` and its TLS and FLS callbacks, after the other threads have been terminated. `FlipQueue`'s destructor then joins a thread that is already gone and waits forever. POSIX `_exit` runs no atexit handlers, stream flushes or module destructors. ### Fix [`AlxcBTW:fix/windows-immediate-exit`](https://github.com/AlxcBTW/AnyPS5/pull/2) (`2feef9e7`, on `main` c963432d). [Full CI](https://github.com/AlxcBTW/AnyPS5/actions/runs/38021728372), with the change merged into `main` c72d5ce1, passes on Linux, macOS and Windows. I can't open it as a PR while intake is limited, so it's here if a collaborator wants to cherry-pick it. `_Exit` (libc) and `_exit` (libkernel) now end the process through `LibcTerminate_nid_no_patch`. That calls `TerminateProcess` on Windows and `std::_Exit` everywhere else. ### Tested Windows 11, WinLibs GCC 15.2.0 r7. - `guest_immediate_exit` now also registers an FLS callback that would end the process with 4. It exits with 4 without the change and with 0 with it. `ctest -R "kill|exit|process|shutdown|atexit|libc|kernel"`: 19/19. - UI Lab: before the change the process stayed alive after `submission retirement failed`. With it, the process exits with 1 (`EXIT_FAILURE`). AI-assisted: yes (Claude Code).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#2579
No description provided.