Closing Syobon Action (PPSA47402) aborts: its exit handler submits a flip after the VideoOut shutdown ("exit thread cannot wait for itself") #5931

Closed
opened 2026-10-14 16:16:06 +00:00 by ahmad3a4 · 4 comments
ahmad3a4 commented 2026-10-14 16:16:06 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by ahmad3a4 on 2026-10-14T16:16:06Z.


What happens

Syobon Action (PPSA47402, 01.001.000 from the homebrew catalog, GPL-3.0, kvaps/syobon-action-ps5) runs on Windows: its SDL start-up passes, it presents frames, and Enter moves on to the lives screen ("× 1") at about 30 FPS. Closing the window then aborts, 4 of 4 runs:

[libc] unhandled exception 'St13runtime_error' thrown from ...
terminate called after throwing an instance of 'std::runtime_error'
  what():  libc: exit thread cannot wait for itself
FATAL: abort() (SIGABRT)

and the process ends with 0xC0000409 instead of exit code 0.

Where

The aborting thread is the exit thread. Its stack, symbolized against the patched libSceVideoOut.prx:

  • libc exit path → the title's own exit handler (eboot.exe+0x27da0 … +0x2acedf)
  • → sceVideoOutSubmitFlip
  • → VideoOutDriver::GetConfig, which throws ProcessShutdown because the flip queue is stopping
  • → the catch in sceVideoOutSubmitFlip calls LibcAwaitExit_nid_postfix
  • → LibcAwaitExit_nid_postfix throws "exit thread cannot wait for itself"

So the title's exit handler (the SDL port's video shutdown, by the look of it) submits one more flip.

Reading main e34c4792:

  • LibcExit_nid_no_patch runs LibcRunShutdown_nid_postfix (the AGC and VideoOut shutdown callbacks) and only then CxaFinalize_nid_no_patch, which runs the guest's atexit/__cxa_atexit handlers.
  • Every VideoOut and AGC entry point turns ProcessShutdown into LibcAwaitExit_nid_postfix. That parks every other thread, but it cannot park the exit thread.
  • So any guest exit handler that calls VideoOut or AGC ends in this abort. That holds for a window close (LibcRequestExit_nid_postfix) and for the title's own exit().

#5277 / #5284 hit the same message from a nested exit(); this is a driver call from an exit handler instead.

Options

  1. Run the guest's exit handlers before the driver shutdown callbacks. On the console, exit() runs the handlers while VideoOut and AGC still work, and other threads keep running until _exit. Other threads would then still be parked by the shutdown token. The exit thread, which runs the handlers, would be let through until the callbacks run.
  2. Don't run the guest's exit handlers on a window close, as #5236 does for sceSystemServiceLoadExec("exit"), because the shell closes a title without them. A title's own exit() would still hit this.
  3. On the exit thread only, return VIDEO_OUT_ERROR_INVALID_HANDLE (and the AGC equivalent) once the drivers are shut down, as if the output had been closed. The handler continues and the remaining handlers run, but the title sees an error the console wouldn't give.

Option 1 matches the console for both kinds of exit. It changes the order set in 39fd90b05, so I'd like to hear which direction you prefer before sending a pull request. I can send it with a test in the style of GuestSystemExit.cpp, where an exit handler calls a VideoOut entry point.

Setup

Windows 11 Pro (26200), RTX 3060 Ti, WinLibs GCC 15.2.0 r7, Release, main e34c4792. The catalog zip (SHA-256 86e763fa…) unpacked and relinked with --windows --to-intel, run from the output folder, closed with WM_CLOSE after 15 to 33 s. Linux not tested.

AI-assisted.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5851352020 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5931). Originally posted by [ahmad3a4](https://github.com/ahmad3a4) on 2026-10-14T16:16:06Z. --- ### What happens Syobon Action (PPSA47402, 01.001.000 from the homebrew catalog, GPL-3.0, [kvaps/syobon-action-ps5](https://github.com/kvaps/syobon-action-ps5)) runs on Windows: its SDL start-up passes, it presents frames, and Enter moves on to the lives screen ("× 1") at about 30 FPS. Closing the window then aborts, 4 of 4 runs: ``` [libc] unhandled exception 'St13runtime_error' thrown from ... terminate called after throwing an instance of 'std::runtime_error' what(): libc: exit thread cannot wait for itself FATAL: abort() (SIGABRT) ``` and the process ends with `0xC0000409` instead of exit code 0. ### Where The aborting thread is the exit thread. Its stack, symbolized against the patched `libSceVideoOut.prx`: - libc exit path → the title's own exit handler (`eboot.exe+0x27da0` … `+0x2acedf`) - → `sceVideoOutSubmitFlip` - → `VideoOutDriver::GetConfig`, which throws `ProcessShutdown` because the flip queue is stopping - → the `catch` in `sceVideoOutSubmitFlip` calls `LibcAwaitExit_nid_postfix` - → `LibcAwaitExit_nid_postfix` throws "exit thread cannot wait for itself" So the title's exit handler (the SDL port's video shutdown, by the look of it) submits one more flip. Reading `main` e34c4792: - `LibcExit_nid_no_patch` runs `LibcRunShutdown_nid_postfix` (the AGC and VideoOut shutdown callbacks) and only then `CxaFinalize_nid_no_patch`, which runs the guest's `atexit`/`__cxa_atexit` handlers. - Every VideoOut and AGC entry point turns `ProcessShutdown` into `LibcAwaitExit_nid_postfix`. That parks every other thread, but it cannot park the exit thread. - So any guest exit handler that calls VideoOut or AGC ends in this abort. That holds for a window close (`LibcRequestExit_nid_postfix`) and for the title's own `exit()`. #5277 / #5284 hit the same message from a nested `exit()`; this is a driver call from an exit handler instead. ### Options 1. **Run the guest's exit handlers before the driver shutdown callbacks.** On the console, `exit()` runs the handlers while VideoOut and AGC still work, and other threads keep running until `_exit`. Other threads would then still be parked by the shutdown token. The exit thread, which runs the handlers, would be let through until the callbacks run. 2. **Don't run the guest's exit handlers on a window close**, as #5236 does for `sceSystemServiceLoadExec("exit")`, because the shell closes a title without them. A title's own `exit()` would still hit this. 3. **On the exit thread only, return `VIDEO_OUT_ERROR_INVALID_HANDLE` (and the AGC equivalent)** once the drivers are shut down, as if the output had been closed. The handler continues and the remaining handlers run, but the title sees an error the console wouldn't give. Option 1 matches the console for both kinds of exit. It changes the order set in 39fd90b05, so I'd like to hear which direction you prefer before sending a pull request. I can send it with a test in the style of `GuestSystemExit.cpp`, where an exit handler calls a VideoOut entry point. ### Setup Windows 11 Pro (26200), RTX 3060 Ti, WinLibs GCC 15.2.0 r7, Release, `main` e34c4792. The catalog zip (SHA-256 `86e763fa…`) unpacked and relinked with `--windows --to-intel`, run from the output folder, closed with `WM_CLOSE` after 15 to 33 s. Linux not tested. AI-assisted.
MarcZX10 commented 2026-10-14 17:59:46 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T17:59:46Z.


PR #5978 addresses the explicit guest exit() and return-from-main path: guest finalizers run while the shutdown token is still live, then the AGC/VideoOut shutdown callbacks run. It depends on #5843, which preserves the separate no-handler path for host window close. The Linux build compiled both changed C++ files and a focused probe passed; the CTest binaries abort at the host CPU-feature guard before the test logic runs, so those tests are not reported as passing.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174886092 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5931#issuecomment-6174886092). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T17:59:46Z. --- PR #5978 addresses the explicit guest `exit()` and return-from-main path: guest finalizers run while the shutdown token is still live, then the AGC/VideoOut shutdown callbacks run. It depends on #5843, which preserves the separate no-handler path for host window close. The Linux build compiled both changed C++ files and a focused probe passed; the CTest binaries abort at the host CPU-feature guard before the test logic runs, so those tests are not reported as passing.
oneandonlydean commented 2026-10-16 23:53:56 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-16T23:53:56Z.


#5978 (29a546d37) is on main now: the guest's exit handlers run before the VideoOut shutdown, which is the flip-after-shutdown shape in your stack. It was tested only in unit tests, not on this title. Could you close Syobon Action again on current main and say whether the exit thread cannot wait for itself abort is gone? If it is, this can close.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6226918250 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5931#issuecomment-6226918250). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-16T23:53:56Z. --- #5978 (29a546d37) is on main now: the guest's exit handlers run before the VideoOut shutdown, which is the flip-after-shutdown shape in your stack. It was tested only in unit tests, not on this title. Could you close Syobon Action again on current main and say whether the `exit thread cannot wait for itself` abort is gone? If it is, this can close.
MarcZX10 commented 2026-10-17 02:32:04 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T02:32:04Z.


The shutdown ordering change from #5978 is now on main and appears to cover the reported flip-after-shutdown path. When convenient, could you close Syobon Action again on current main and report whether the abort is gone? If it persists, the current log and tested commit would help isolate what remains.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6228543132 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5931#issuecomment-6228543132). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T02:32:04Z. --- The shutdown ordering change from #5978 is now on `main` and appears to cover the reported flip-after-shutdown path. When convenient, could you close Syobon Action again on current `main` and report whether the abort is gone? If it persists, the current log and tested commit would help isolate what remains.
ahmad3a4 commented 2026-10-18 12:27:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by ahmad3a4 on 2026-10-18T12:27:01Z.


Checked on current main 0d078f75d (with #5843 and #5978): the abort is gone.

Windows 11 Pro, i5-13400, WinLibs GCC 15.2.0 r7, Release. Syobon Action (PPSA47402) relinked with main's relinker, run to the title screen (30 FPS) and closed through the window after 15 s, 3 times: exit code 0 each time, with no exit thread cannot wait for itself and no abort in the log. Before #5843 and #5978 the same close aborted every time.

Closing this. Thanks @MarcZX100, @Ondra97 and @oneandonlydean.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249903253 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5931#issuecomment-6249903253). Originally posted by [ahmad3a4](https://github.com/ahmad3a4) on 2026-10-18T12:27:01Z. --- Checked on current main 0d078f75d (with #5843 and #5978): the abort is gone. Windows 11 Pro, i5-13400, WinLibs GCC 15.2.0 r7, Release. Syobon Action (PPSA47402) relinked with main's relinker, run to the title screen (30 FPS) and closed through the window after 15 s, 3 times: exit code 0 each time, with no `exit thread cannot wait for itself` and no abort in the log. Before #5843 and #5978 the same close aborted every time. Closing this. Thanks @MarcZX100, @Ondra97 and @oneandonlydean.
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#5931
No description provided.