feat(libkernel): implement the rtld thread atexit reference count #722
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/722"
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 alfalfa-star on 2026-10-05T18:00:38Z.
What
Implement
_sceKernelRtldThreadAtexitIncrementand_sceKernelRtldThreadAtexitDecrement(and the variants without the leading underscore), which threw.A title's own
libc.prxcalls Increment from__cxa_thread_atexitwith thedsoaddress and fails the registration when it returns nonzero (seen in a debugger on PPSA14632). The previousuint64_t*signature was wrong: the argument is an address inside the module that registers thethread_localdestructor. As in fpPS4, Increment takes a reference on the loaded image that contains the address, so the image stays mapped while its destructors are pending, and Decrement releases one. On Linux the reference is adlopen(RTLD_NOLOAD)handle of the image found throughdladdr1; on Windows it isGetModuleHandleExW(FROM_ADDRESS). The main executable is counted but needs no handle. An address outside every loaded image and a Decrement without a matching Increment throw. The assumed semantics are recorded in TechnicalDebt.Tested
guest_dynamic_loadernow pins the fixture module, closes every handle, and still calls into it; with the pin disabled the test segfaults. It also checks the main executable, the unbalanced Decrement and an address outside every image. Full ctest: 290/290 apart from the three wave64 pixel tests that fail onmainon this GPU (RX 9070 XT, RADV).__cxa_thread_atexitnow succeeds and it continues tosceKernelGetModuleInfoFromAddr(separate PR).#717 also edits
core/libs/tests/GuestDynamicLoader.cpp(a different topic); whichever lands second needs a small rebase there.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T23:37:45Z.
This needs a rebase now that #717 has landed:
core/libs/tests/GuestDynamicLoader.cppconflicts with currentmain, in the includes (mainadds<filesystem>/<fstream>, you add<stdexcept>) and at the end ofmain(), where #717's relinked-module case and your new cases were both appended. Keeping both sides (all three includes, #717's case and then yours) should resolve it. Nothing else conflicts.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-06T13:10:16Z.
Progress report (
5895ea7→5e009d7)📈 System libraries: 87.14% (+0.14%, +4 implemented functions)
✅ 4 implemented
_sceKernelRtldThreadAtexitDecrement_nid_postfix_sceKernelRtldThreadAtexitIncrement_nid_postfixsceKernelRtldThreadAtexitDecrementsceKernelRtldThreadAtexitIncrement