libSceSystemService: sceSystemServiceLoadExec("exit") runs the title's exit handlers, which the console doesn't; Wind Waker (PPSA99309) segfaults in one #5235

Closed
opened 2026-10-13 15:22:49 +00:00 by David-cmrg · 0 comments
David-cmrg commented 2026-10-13 15:22:49 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by David-cmrg on 2026-10-13T15:22:49Z.


PS5_SwitchWaker (Wind Waker, PPSA99309, catalog 1.0.1) without a disc image shows "no game found" and then asks the shell to close it. On Linux, main 9510e71d6, llvmpipe, the process then ends with a segmentation fault (exit code 139) instead of exit code 0:

[debug:0] [Wind Waker] [notification] Wind Waker: no game found.
[debug:0] [Wind Waker] Copy your own disc image of The Wind Waker (USA, GZLE01, .iso) into /data/homebrew/PPSA99309/ or onto a USB drive, then start again.
[debug:0] [Wind Waker] exit status 14: asking the shell to close the title
timeout: the monitored command dumped core

The title ends in its own catchReturnFromMain, which its CRT calls after main returns (ps5/src/platform.c). It calls sceSystemServiceLoadExec("exit", NULL) and then sleeps forever. Its comment gives the reason: exit() and returning from _start both kill the title and "the console then reports a crash over a run that worked"; the shell closes the title asynchronously, so the title must wait and never return. VLC for PS5 ends the same way, with _exit(0) right after sceSystemServiceLoadExec("exit", NULL) (plat_quit). So on the console, a title's atexit and __cxa_atexit handlers don't run after sceSystemServiceLoadExec("exit").

AnyPS5 runs them. sceSystemServiceLoadExec("exit") calls LibcExit_nid_no_patch(0), which runs LibcRunShutdown, then CxaFinalize(nullptr), then std::exit. In gdb, the main thread enters CxaFinalize after LibcRunShutdown and then faults in the title's code, in one of its __cxa_atexit destructors. Going by the code, they also ran before #4872, from the host atexit entry that the title's first __cxa_atexit registers.

Ending "exit" with LibcRunShutdown, a flush and LibcTerminate, without the title's handlers, would match the console. #4846 would stay fixed, because no guest code runs during the exit.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5833000899 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5235). Originally posted by [David-cmrg](https://github.com/David-cmrg) on 2026-10-13T15:22:49Z. --- PS5_SwitchWaker (Wind Waker, PPSA99309, catalog 1.0.1) without a disc image shows "no game found" and then asks the shell to close it. On Linux, `main` `9510e71d6`, llvmpipe, the process then ends with a segmentation fault (exit code 139) instead of exit code 0: ``` [debug:0] [Wind Waker] [notification] Wind Waker: no game found. [debug:0] [Wind Waker] Copy your own disc image of The Wind Waker (USA, GZLE01, .iso) into /data/homebrew/PPSA99309/ or onto a USB drive, then start again. [debug:0] [Wind Waker] exit status 14: asking the shell to close the title timeout: the monitored command dumped core ``` The title ends in its own `catchReturnFromMain`, which its CRT calls after `main` returns ([`ps5/src/platform.c`](https://github.com/griches/PS5_SwitchWaker/blob/3c0f213f2d4c17606ac8637eda2c5da6cbcc73b0/ps5/src/platform.c#L77-L89)). It calls `sceSystemServiceLoadExec("exit", NULL)` and then sleeps forever. Its comment gives the reason: `exit()` and returning from `_start` both kill the title and "the console then reports a crash over a run that worked"; the shell closes the title asynchronously, so the title must wait and never return. VLC for PS5 ends the same way, with `_exit(0)` right after `sceSystemServiceLoadExec("exit", NULL)` ([`plat_quit`](https://github.com/ZiZc3/VLC/blob/d46be6a68f4244466b041c2dc1b640915ac1a983/src/platform_ps5.c#L555-L560)). So on the console, a title's `atexit` and `__cxa_atexit` handlers don't run after `sceSystemServiceLoadExec("exit")`. AnyPS5 runs them. `sceSystemServiceLoadExec("exit")` calls `LibcExit_nid_no_patch(0)`, which runs `LibcRunShutdown`, then `CxaFinalize(nullptr)`, then `std::exit`. In gdb, the main thread enters `CxaFinalize` after `LibcRunShutdown` and then faults in the title's code, in one of its `__cxa_atexit` destructors. Going by the code, they also ran before #4872, from the host `atexit` entry that the title's first `__cxa_atexit` registers. Ending `"exit"` with `LibcRunShutdown`, a flush and `LibcTerminate`, without the title's handlers, would match the console. #4846 would stay fixed, because no guest code runs during the exit.
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#5235
No description provided.