fix: stop guest exits from running host teardown #1688
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1688
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1688/head"
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?
@joedeangelis533-bot on GitHub · 2026-10-19 03:39 UTC · original
joedeangelis533-bot:fix/guest-exit-host-teardown→main· +155 −20 · 6 files · 1 commits · closed without mergingGame problem
Mafia: The Old Country (PPSA14299) and Astro Bot (PPSA21564) are reported in #1540, section 4, to crash during guest exit when host teardown releases guest memory or configuration while other threads are still running. That report used a custom Linux build; its game runs have not been independently reproduced here.
On current upstream, both the libc and libkernel exit exports call host
::exit, which runs host atexit callbacks and static teardown before terminating the process.Change
Register both exit NIDs against one SysV-ABI entry point that uses the existing
Common::DbgExitroutine. That runs the registered emergency cleanup callbacks, flushes C streams and callsstd::_Exit, preserving the guest status while avoiding normal host teardown.Add a regression executable to CMake/CTest,
kyty_tests, and the Windows, Linux and macOS CI build/test selections. The test keeps another thread alive and checks exits from both the main thread and a worker.This addresses the exit-time failure mechanism only. It does not fix the APR/content-loading or guest-stdout problems also described in #1540, so it should not close that whole issue. #1569 addresses the separate guest-stdout request.
Validation
Local Windows x86-64, Clang 23.1.3 / LLVM-MinGW, C++20:
::exitbehavior reaches the host teardown guard in all six cases, returning 97 instead of the requested status.guestExit.h,assert.cpp,subsystems.cppand test source; only unrelated fatal-report logging functions are stubbed in that local harness.git diff --checkpasses.The full emulator, the normal Visual Studio clang-cl build, Linux/macOS runtime tests and the commercial games have not been run locally. The isolated test build does not replace full project CI or game retesting.
Review points
Normal host destructors are deliberately skipped. Persistence must use the existing emergency callbacks or explicit flushing; destructor-only graphics cache persistence is separate work in #1312. The two exit exports also lose their former optional
PRINT_NAMEtrace when sharing the entry point.AI assistance
Prepared with Codex for the contributor, who explicitly directed submission of this patch. AI assistance covered investigation, implementation, regression tests, automated validation and this description. No independent human code review or commercial-game test result is claimed; the validation above was automated locally.
@coderabbitai[bot] on GitHub · 2026-10-19 03:43 UTC · original
📝 Walkthrough
The change adds
Libs::GuestExit, which callsCommon::DbgExit, and routes the guest exit exports inlibC.cppandlibKernel.cppto that function. It adds child-process tests for several exit statuses on main and worker threads, registers the tests with CMake, and selects them in the Windows, macOS, and Linux workflows.Suggested reviewers:
nmzikPriority: ⬇️ Low
Change: Bug fix
Merge Risk: 🔵 Low · up to
564d0Guest exit behavior is tested, but a regression in either export binding could go undetected. Add binding coverage or accept that bounded gap before merging.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 4 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-19 03:43 UTC · original · reviewed
🧹 Nitpick comments: 1
ℹ️ Review info
⚙️ Run configuration
e6ec303a-4bfc-4ad7-baa2-cc9f78010ff1📥 Commits
Reviewing files that changed from the base of the PR and between
099de8dea6and564d066807.📒 Files selected for processing: 6
.github/workflows/build.ymlCMakeLists.txtsrc/libs/guestExit.hsrc/libs/libC.cppsrc/libs/libKernel.cpptests/GuestExitTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Pull request closed