fix(libc): skip guest exit handlers on host window close #5843
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5843"
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 Ondra97 on 2026-10-14T13:36:17Z.
What
Closing the native VLC v0.4 (PPSA85300) window aborts the process, as reported in the #5791 validation.
SDL_QUITcallsLibcRequestExit_nid_postfix, whose detached thread currently runs the guest finalizers. VLC still has a joinable C++ thread object; its destructor callsterminate()and thenabort().The asynchronous host exit request now uses
LibcExitWithoutHandlers_nid_no_patchfrom #5236. It runs the registered runtime shutdown callbacks, flushes the host streams and terminates without guest or host exit handlers. The newguest_requested_exitmode reuses the existing exit fixture: shutdown must complete, another guest thread must stay parked during shutdown, both kinds of exit handler must remain uncalled, and a second request with status 7 must leave the first request's status 0 intact. Its parent checks the child's actual exit code.#5236 is merged into
main. This PR now contains only the host-window-close change and its regression (three files). #5978 remains a separate dependent follow-up for explicit guestexit()and return from main.Tested
Rebase validation on Windows 11 Pro build 26300, WinLibs GCC 15.2.0, Ninja Release: head
eb8146b73, based onmain0ae1deb85. #5236 is merged into this base.patched_libraries.python tools/check_conventions.py --base origin/main,git diff --checkandpython tools/check_main_sync.py --base origin/mainpassed; clean merge, 0 behind at publication.git range-diffconfirms that the host-window-close patch is unchanged. ProductionProcess.cppis byte-identical to the original title-tested PR head. The PR now has one commit and three changed files; the merged prerequisite is no longer carried as a separate commit.No new title run or Linux run was performed for this rebase. The original title validation below was performed before the rebase:
Windows 11 Pro build 26300, WinLibs GCC 15.2.0, Ninja Release. Original head
e0748f372, based onmain5a6ad0ed3plus #5236:Guest shutdown completedfollowed byGuest exit handler ran; CTest fails in 0.17 s. That PR alone does not fix host window closure.--windows --registry --windows-diagnostics --windows-fixed-base 0x400000, including its own libc module. Executable ELF SHA-256:eec51934aa2debed99152c3996f39a41be25e17d9ca14de01cee2d17b62d8e3f. All 132 installed runtime files were checked against the build by SHA-256.main550764236, a visible 20 s run ends with0xc0000409afterCloseMainWindow()returns true. GDB reachesLibcExit->CxaFinalize; the guest destructor at0x2261f30calls termination when its first word is nonzero, andabort_nid_postfixis reached from0x22c49af. The adjacent functions carrythread::join failedandthread::detach failed, and the destructor matches libc++'s thread destructor.Process.cppis byte-identical on that baseline and final base5a6ad0ed3.APS5_NO_DRAW_SRT_ENTRIES=1both close normally with exit code 0, without a timeout or forced kill. The latter displays the complete welcome screen and 16 language buttons. Disabling that cache isolates shutdown from the rendering bug fixed by #5791; this PR changes no rendering code. Media playback and a local Linux run were not tested.python tools/check_conventions.py --base origin/main,git diff --checkandpython tools/check_main_sync.py --base origin/mainpassed; clean merge, 0 behind.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt.mdfiles or images added to the repository (evidence recorded in this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T17:50:50Z.
I have a separate follow-up for #5931 covering explicit guest
exit()and return-from-main: run guest finalizers while VideoOut/AGC are still available, then run the registered shutdown callbacks. It leaves your host-window-close path onLibcExitWithoutHandlersunchanged and declaresDepends on: #5843. The regression checks the shutdown token is still live during a guest finalizer, including the normal nested-exit path. Please let me know if that stacking order conflicts with your intended change; I will keep the scope separate.Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-14T17:56:34Z.
Thanks @MarcZX100, that ordering fits the intended scope of #5843. The dependency order would be #5236 → #5843 → your follow-up.
Please keep
guest_requested_exitandguest_system_exitpassing: both must still skip guest and host exit handlers. For explicit guestexit()and return-from-main, keeping VideoOut/AGC available through the remaining finalizers, including nestedexit(), makes sense. The shutdown callbacks should then run once.AI-assisted: yes. — Codex
Imported from boykopovar/AnyPS5. Originally posted by ahmad3a4 on 2026-10-14T18:20:08Z.
Windows check with the title from #5931. With this PR (e0748f37) on
mained835aa7, closing Syobon Action (PPSA47402) withWM_CLOSEends with exit code 0 in 3 of 3 runs. Onmaine34c4792it aborted 4 of 4 times withlibc: exit thread cannot wait for itself.guest_requested_exitand the other exit tests pass here too.The run was stacked with #5978, so the merge resolution is in https://github.com/boykopovar/AnyPS5/pull/5978#issuecomment-6175265846. Keep
LibcRunShutdown_nid_postfix()inLibcExitWithoutHandlers_nid_no_patchonceStartExitno longer runs it.AI-assisted.
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-14T18:31:39Z.
Thanks @ahmad3a4 for validating the combined tree. The merge resolution is correct: once
StartExit()no longer runs shutdown,LibcExitWithoutHandlers_nid_no_patch()must callLibcRunShutdown_nid_postfix()before flushing and terminating.@MarcZX100, one remaining coverage gap in #5978:
guest_nested_exitcurrently checks the remaining handler and exit code, but does not register a shutdown callback or check the token. Please extend it to verify that the remaining finalizer sees a live token and that shutdown runs exactly once afterward.AI-assisted: yes. — Codex
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-15T01:53:39Z.
Windows/NVIDIA check with VLC (PPSA85300 v0.4, catalog release).
eb8146b73merged ontomain2559e9623: clean, no conflicts (merge87c4dc4a6). Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, NVIDIA GeForce RTX 4070 (driver 596.21).libspass, no new warnings.--repeat until-fail:3:guest_requested_exit,guest_system_exit,guest_system_exit_parameters,guest_quick_exit,guest_immediate_exit,guest_return_from_main,guest_system_relaunch,guest_nested_exit: 8/8, 3 of 3.guest_system_exit_tests.exe --requested-exit-driverwithmain'slibc.prxfirst onPATHprintsGuest shutdown completed,Guest exit handler ran,FATAL: abort() (SIGABRT)(3 of 3).ctest -j8 --timeout 120 -E '^agc_driver_|^video_out_flip': 813/813 passed (2 skipped, the same as onmain:agc_host_import_sparse,guest_video_out_wqhd_detection_no_vulkan).relinker --windows --registry unused-filter=0 --windows-fixed-base 0x400000, identical procedure for both builds, visible window,WM_CLOSEposted to it at 45 s:WM_CLOSEmain2559e96230xC0000409after 0.8 / 3.2 / 1.4 sVLC | FPS: 46.23 (2458),48.98 (2263),41.19 (1647)main+ #58430after 0.8 / 1.4 sVLC | FPS: 57.05 (3020),75.20 (2692)Neither build prints a stop line. Every log ends at
[src/Thread.cpp:527 RunThread] RunThread entry=0x22d3f60 arg=00000020000228c0 self=…, and onmainthe abort leaves only the exit code. Both builds show the same screen (gradient and page dots; the text needs #5791).Verdict: on NVIDIA, closing the VLC window now exits 0 instead of aborting, with no test regressions.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-15T01:58:45Z.
A Linux run with the title from #5931: Syobon Action (PPSA47402, catalog 01.001.000), Ubuntu 24.04, GCC 13.3, Release,
mainab9a47684. The window was closed withwmctrl -c20 s in, while the title was presenting:main: exits 134 withlibc: exit thread cannot wait for itself.main+ this PR alone: exits 0.main+ this PR + #5978: exits 0.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:10:17Z.
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.
core/libs/prx/libSceSystemService/CMakeLists.txtcore/libs/tests/GuestSystemExit.cppcore/libs/prx/libc/src/Process.cppImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T13:36:39Z.
Checked on the PR merged onto current main: build and scoped ctest green (119/119, no skips).
guest_requested_exitfails when theProcess.cppchange is reverted and passes with it;LibcExitWithoutHandlers_nid_no_patchstill runs the shutdown callbacks throughStartExit. Windows and Linux title runs by @ahmad3a4, @screamm and @milescoviello cover what we can't run here; merging once the full Build is green.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T21:05:47Z.
I added the missing coverage to #5978 and rebased that PR onto current
main(de974eb83). The nested-exit child now registers a shutdown callback and a remaining finalizer that asserts the shutdown token is still live; the exact marker sequence also verifies the finalizer runs before shutdown and the callback runs once. The existing exit-code and remaining-handler checks stay in place.The test source syntax check and conventions check pass. I have not rerun the runtime CTest on this host; the earlier attempt stopped at the host CPU-feature guard before entering the test body. Hosted checks are starting on the rebased head.