libSceLibcInternal: inventory stub oly3wSwEJ2A is std::system_error(error_code, const char*), and the NID patch step fails whenever libc stops exporting libstdc++'s copy of it #15955
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 StepFPV on 2026-11-05T02:46:42Z.
What happens
An ASan+UBSan build of
mainb611e634f7with GCC 16.1.1 (-DANYPS5_ENABLE_ASAN=ON,-fsanitize=undefined -fno-sanitize=vptr,-march=x86-64-v3, the Sanitizers workflow's flags) stops in the NID patch step:avplayer_http_patched_modules,guest_sigvec_modulesand the ten tests that stagelibSceLibcInternal.prxare not run. The same tree builds with GCC 16 in Release, and the nightly Sanitizers run (GCC 15) builds it too.Why
InventoryExports.cpp:100exports aNotImplementedstub under the NIDoly3wSwEJ2A:That NID is the hash of the mangled name
_ZNSt12system_errorC2ESt10error_codePKc, i.e.std::system_error::system_error(std::error_code, const char*)(base-object constructor); the console'slibSceLibcInternalexports the C++ runtime under mangled-name NIDs, and this one is simply not implemented yet.libstdc++ defines that constructor inline, so every module that throws
std::system_error(ec, "text")carries a weak copy of it.libSceLibcInternaldoes (Spawn.cpp:135), and so doeslibc.libSceLibcInternalis patched with--preserve-export-list libc.exports, so as long as libc's own export list contains_ZNSt12system_errorC2ESt10error_codePKc, the copy inlibSceLibcInternalkeeps its name and only the stub providesoly3wSwEJ2A. When libc's build does not export that copy, the patcher hasheslibSceLibcInternal's copy tooly3wSwEJ2A, finds the stub's alias at another address and stops (ElfNidPatcher.cpp:518).Swapping the inputs confirms it: the sanitizer module patched with the Release
libc.exportssucceeds; the Release module patched with the sanitizerlibc.exportsfails. Whether libc exports the weak symbol depends on the compiler and flags (GCC 16 Release: yes; GCC 16 ASan+UBSan: no; GCC 15 ASan+UBSan on ubuntu-latest: yes; MinGW: theC1variant), so any libc change that stops instantiatingstd::system_error(error_code, const char*)out of line breaks the Release build on every host.A scan of all 830
APS5_EXPORTinventory NIDs across 15 libraries against the dynamic symbols of every module finds no other collision;libSceLibcInternalexports 2062 symbols, 2039 of them NID-suffixed, 12 intended plain names (sceLibcHeap*,sceLibcPafMspace*,sceLibcInternalSetMallocCallback,sceLibcMspaceSetMallocCallback,SpawnProgram) and 11 leaked libstdc++ instantiations.Options
libSceLibcInternal(a generated version script /.def/-exported_symbols_list, aslibSceJson2does), so libstdc++ instantiations never reach the patcher. The 12 plain-name exports have to stay on the list.std::system_error(std::error_code, const char*)in libc next to the otherstd::system_errormembers (libc/src/exception/StandardExceptions.cpp:502-518) and drop the stub; the message needs the guesterror_category::messagecall._nid_no_patch_cutalias over a weak symbol that hashes to the same NID, or skip weak (STB_WEAK) symbols when hashing.Removing the stub alone (the #2462/#2473 pattern) is not enough here: in Release the leaked copy is preserved under its plain name, so
libSceLibcInternalwould stop exportingoly3wSwEJ2Aat all.Environment
Arch Linux in WSL2, GCC 16.1.1, Ninja; also checked the Release x86-64-v3 build (passes) and the Windows 11 WinLibs GCC 15.2.0 build (passes,
libc.exportslists theC1variant).AI-assisted: yes