fix(libc): export __cxa_thread_atexit through the existing callback b… #5090
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5090"
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 MrMha on 2026-10-13T11:18:14Z.
What
Void Terrarium (PPSA03061) reports an unresolved
libc.prximport,BKSCW2bCACA, when using the host libc (#5055). This is the NID of__cxa_thread_atexit.Add the missing export as a forwarding wrapper to the existing
__cxa_thread_atexit_implcallback bridge. The wrapper forwards the destructor, object and DSO arguments unchanged and returns the registration result. ExtendGuestThreadCallbackAbi.cppto register through the new export and verify that four destructors execute once, in reverse registration order, with the original object pointers and after the worker exits.Addresses #5055. Resolution of the missing import does not establish further title compatibility.
Tested
Prior local validation recorded for head
bda3cda2c7eee5eb9f242a08dc4732729f5693b3: Linux x86-64, GCC 13.3, Python 3.12.-Wall -Wextra -Werror, function/data sections and linker garbage collection.BKSCW2bCACA.These results were supplied in the attached work record and were not rerun in this description review. No full runtime build/CTest, patched-library loading, Windows/macOS execution or Void Terrarium run is claimed. The inspected GitHub full Linux/Windows runtime jobs were skipped; passing relinker jobs do not validate this libc change.
Outstanding work
5d50886ee4045dc2a081d8d93bf8e667f6d82325, this branch was 43 main commits behind, with merge baseae244d527ab201f56e43c664f81e145d57370eba. Update the branch and validate the resulting head.Checklist
main; no other open PR implements the same functions (see outstanding work above)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T11:25:20Z.
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/src/CxxAbiSupport.cppL85core/libs/tests/GuestThreadCallbackAbi.cppL16, L27, L39, L64, L71, L87__cxa_thread_atexit_nid_postfixImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T11:36:03Z.
Progress report (
5d50886→bda3cda)➖ System libraries: 87.86% (+0.0%, +1 implemented functions)
✅ 1 implemented
__cxa_thread_atexit_nid_postfixImported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T11:44:57Z.
Review note (static): this adds the same function as the older open #5065 (opened 10:19Z; this one 11:18Z): a forwarding
__cxa_thread_atexit_nid_postfixto__cxa_thread_atexit_impl_nid_postfixplus an extension ofGuestThreadCallbackAbi.cpp.git merge-treeof the two heads reports conflicts inCxxAbiSupport.cppandGuestThreadCallbackAbi.cpp, so only one can land. This PR has the better text (it names the issue it fixes, Void Terrarium #5055, and checks that the destructors run only at thread exit); maybe the two authors can agree on one PR. The export name is right: SHA-1 of__cxa_thread_atexitgivesBKSCW2bCACA.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-13T13:04:12Z.
Review note on Windows, from reading the code and the MinGW source (not run on Windows here):
On Windows this export passes the guest's
dsothrough__cxa_thread_atexit_impl_nid_postfixto MinGW's__cxa_thread_atexit, which asserts!dso || dso == &__dso_handle(tls_atexit.c#L70). A guest passes its own module's__dso_handle, so the assertion fires. With this change applied, the Void Terrarium report in #5055 hits exactly this assertion, and gets past it by passingnullptras the DSO.mainalready does this for the other export:LibcInternalExtCxaThreadAtexit_nid_postfixpassesnullptron_WIN32(CxxAbiSupport.cpp#L86-L92,9f81bddf6). Fix options:_WIN32null-DSO rule into__cxa_thread_atexit_impl_nid_postfixitself. That also covers a guest that calls the existing__cxa_thread_atexit_implexport with its own DSO.The Windows run of
guest_thread_callback_abican't show this. The test setsdirectDso = nullptron_WIN32(GuestThreadCallbackAbi.cpp#L57-L60), so on Windows the new export is only ever called with a null DSO. A Windows case with a non-null pointer that is not the host's__dso_handlewould cover it.AI-assisted: written with Claude Code; I checked the code paths and the MinGW source linked above.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T13:07:04Z.
Closing as a duplicate: #5065 (opened an hour earlier) adds the same
__cxa_thread_atexitforwarding wrapper and the same extension ofguest_thread_callback_abi, and the two conflict inCxxAbiSupport.cppandGuestThreadCallbackAbi.cpp, so only one can land. CONTRIBUTING asks for a single open PR per function, and the first checklist item here is unchecked for that reason.Both PRs also share the Windows problem reported by @nikowolf123: the guest's
dsogoes unchanged to MinGW's__cxa_thread_atexit, which asserts!dso || dso == &__dso_handle(this is the assertion hit in #5055).LibcInternalExtCxaThreadAtexit_nid_postfixalready passesnullptron_WIN32; the export should do the same (or__cxa_thread_atexit_impl_nid_postfixshould), with a Windows test case using a non-null DSO.Please continue on #5065 with that fix. You're welcome to reopen this one if #5065 is dropped.
Pull request closed