feat(libcinternal): run thread_local destructors at thread exit #641
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/641"
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 Celegans12 on 2026-10-05T10:36:01Z.
What
A title that bundles its own
libc.prxstops at startup on three unresolved libSceLibcInternalExt imports, which that libc uses forthread_localdestructors._sceLibcInternalThreadAtexit(qBS714-Jr3g),int(void (*)(void*), void*, void*): appends{destructor, object, dso}to the calling thread's list and returns 0. The first call installs the pass as libkernel's thread exit hook (sceKernelSetThreadDtors)._sceLibcInternalThreadDtors(OQ-dzhlnM28),void(): runs the thread's destructors newest first, including ones registered meanwhile._sceLibcInternalForceTlsDestructor(tB59hFLH3SA): throws; behaviour unknown.Source: FreeBSD
lib/libc/stdlib/cxa_thread_atexit_impl.c, except:_sceLibcInternalForceTlsDestructor.ENOMEM.Call sites in PPSA26344 v1.008
libc.prx:__cxa_thread_atexit(0x7ecd0) forwards to the first,exitcalls the second (0x3ab19),__cxa_finalizepasses a dso's module handle to the third (0x3aa5c).Neither the executable nor
libc.prximportssceKernelSetThreadDtors(+mR4CLzg3S0) or_sceKernelSetThreadDtors(rNhWz+lvOMU), so the hook is free; if another module took it, the first registration throws. libc'sLibcInternalExtCxaThreadAtexit(Ydzc7qlDvCw) is unchanged: neither module imports it, and it keeps using the host__cxa_thread_atexit.TechnicalDebt: the assumptions under "Unknown function info"; under "Functional", threads libkernel did not start run destructors only via
_sceLibcInternalThreadDtors. A newCMakeLists.txtregisters the test and links${CMAKE_DL_LIBS}(dladdron Linux).Tested
Windows 11, MinGW-w64 GCC 15.2.0, based on
main53dc19cf: configure-DBUILD_TESTING=ON, full build,--target libs,ctest:285/285 tests pass (
ctest --output-on-failure)New
guest_thread_atexitcovers:scePthreadCreatethread's destructors running on that thread before join;It does not link on
main.PPSA26344 v1.008: the three imports that stop startup on
mainresolve, and the title gets past startup. That run predates one change: a non-image destructor was then logged and skipped instead of throwing.Not tested: Linux (CI), module unloading, console behaviour.
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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-05T16:06:47Z.
Progress report (
e248f40→2dea716)📉 System libraries: 79.19% (-0.01%, +2 implemented, +1 declared functions)
✅ 2 implemented
_sceLibcInternalThreadAtexit_nid_postfix_sceLibcInternalThreadDtors_nid_postfix🆕 1 declared as stubs
_sceLibcInternalForceTlsDestructor_nid_postfix