feat(libc): implement at_quick_exit and quick_exit #405
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/405"
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 Pouare514 on 2026-10-02T20:10:05Z.
What
Our libc had no quick_exit/at_quick_exit. Cyberpunk 2077 (PPSA04029) imports quick_exit (NID qdGFBoLVNKI, hash-verified) and calls it during startup; without it the game cannot terminate cleanly.
Change: at_quick_exit registers handlers (LIFO); quick_exit runs them then terminates via _Exit, mirroring the existing atexit machinery with a separate handler list as the standard requires. Covered by a new guest_quick_exit test (handler order enforced via exit codes plus output match).
Tested
Checklist
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-02T20:11:26Z.
Progress report (
33a870d→9e70325)📈 System libraries: 78.88% (+0.04%, +2 implemented, -1 removed functions)
✅ 2 implemented
at_quick_exit_nid_postfixquick_exit_nid_postfix🗑️ 1 removed
libcCyberUnknown15Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T05:44:21Z.
Thanks, the handler order and the separate list match C11 and FreeBSD's
quick_exit.c. The Linux job fails on the newguest_quick_exittest:quick_exitends in_Exit, which doesn't flush stdio, and under ctest stdout is a pipe, so theputsfrom the handler never reaches the output. The implementation is correct to not flush; addingstd::fflush(stdout);after theputsinQuickFirstshould make the test pass on both platforms.Imported from boykopovar/AnyPS5. Originally posted by Pouare514 on 2026-10-04T13:26:02Z.
Done: added std::fflush(stdout) after the puts in QuickFirst. guest_quick_exit passes now (also guest_system_exit + parameters, 3/3 green locally).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T21:07:50Z.
Thanks,
guest_quick_exitpasses on Linux now. The Windows job fails earlier, in the build:nid_patcherstops withduplicate patched export name: qdGFBoLVNKIfor libc. qdGFBoLVNKI is the NID ofquick_exit, and main already exports it as the stublibcCyberUnknown15inlibc/Export.cpp(from #358). Removing that stub should fix it.at_quick_exit(HC8vbJStYVY) isn't on main, so it doesn't clash.Imported from boykopovar/AnyPS5. Originally posted by Pouare514 on 2026-10-04T22:54:18Z.
Done: removed the libcCyberUnknown15 stub for qdGFBoLVNKI, so quick_exit_nid_postfix is the only export of that NID. Windows build is green locally (libs target) and guest_quick_exit passes.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-04T23:10:09Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libc/Export.cppL115-173Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T23:43:42Z.
Thanks, with
libcCyberUnknown15gonequick_exitis the only export of qdGFBoLVNKI, and both CI jobs are green now, includingguest_quick_exiton Windows. It also passes here on this head merged with current main. Ready to merge from my side.For whoever lands second: #492 also edits
libc/Export.cppnear this stub (the overlap bot lists it), so that one may need a small rebase.