feat(libSceLibcInternal): forward the sized nothrow deletes and iostream_category to libc #14796
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14796"
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 maskym on 2026-11-01T18:03:31Z.
What
Three
libSceLibcInternalinventory placeholders threw on every call:_ZdlPvmRKSt9nothrow_t(NID7VPIYFpwU2A),_ZdaPvmRKSt9nothrow_t(7lCihI18N9I) and_ZSt17iostream_categoryv(V23qt24VPVs). Their mangled names fix the prototypes:operator delete(void*, std::size_t, const std::nothrow_t&),operator delete[](void*, std::size_t, const std::nothrow_t&)andstd::iostream_category().libcalready implements the sized deletes (_ZdlPvm,_ZdaPvm, which release the block on the application heap and ignore the size) and the category, soCxxRuntimeForwards.cppruns that code under thelibSceLibcInternalNIDs, the way #14240 did for the aligned arraynewanddeleteinAlignedNew.cpp. Thenothrowdeletes arenoexcept, as the standard forms are. The three inventory stubs and their debt entries are replaced by one entry that records what is and is not verified: the console'slibSceLibcInternal.sprxwas not read, and whether its deletes sharelibc.prx's heap or its category object is distinct fromlibc.prx's is unknown.Tested
Windows 11 26300, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh), Release,
BUILD_TESTING=ON, no title. Newguest_libc_internal_cxx_forwardsregisters a recording application heap and checks that both deletes release the given block exactly once, that a null pointer releases nothing, and that the category pointer is non-null, equal tolibc's_ZSt17iostream_categoryvobject and stable across calls, withname()iostream: 3 of 3 runs pass.ctest -R '^guest_(libc_internal|init_once|statvfs|fstatvfs|fdopendir|opendir2|utime|posix_spawn|program_name)': 13/13. The patchedlibSceLibcInternal.prxexports the three NIDs (objdump -p).python tools/check_conventions.py --base origin/mainpasses;tools/pr_overlap.pylists #14373 and #14659, which add declarations at the sameApi.hppline (text overlap only). Not run on Linux, macOS or a PS5.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T18:08:00Z.
Review: DISMISSED
Reviewed — changes requested
The new wrappers assume that
libSceLibcInternalshareslibc's application heap andiostream_categoryobject, but the PR records that both console behaviors are unverified.What I ran
Reviewed head
92b77cf73639ed1848e5f9ec99967ef89fa1a576against basef2d874c1fdccf781c0fa5d86619bb5dd8894b958; Git's merge preview against that base was clean. Environment: Linux 6.1, Python 3.11.2, Git 2.39.5; no C++ compiler invocation.Command results and complete precheck table
git diff --checkexited 0 with empty stdout. Conventions output:Public-header audit output:
ABI audit output summary:
Test-quality heuristic output:
Complete precheck table (the
failedtool rows are launch errors in the local isolated checkout, not findings against the PR):The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check f2d874c1fdccf781c0fa5d86619bb5dd8894b958...92b77cf73639ed1848e5f9ec99967ef89fa1a576/usr/bin/python3 tools/check_conventions.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head 92b77cf73639ed1848e5f9ec99967ef89fa1a576 --title feat(libSceLibcInternal): forward the sized nothrow deletes and iostream_category to libc --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14796-92b77cf73639/pr-body.md/usr/bin/python3 tools/pr_abi_audit.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head 92b77cf73639ed1848e5f9ec99967ef89fa1a576 --jsonNo changed Python implementation files.No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.No changed test_*.py files./usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14796 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14796-92b77cf73639/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./usr/bin/python3 /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14796-92b77cf73639/head-92b77cf73639-7ef63000/tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14796-92b77cf73639/head-92b77cf73639-7ef63000 --json core/libs/prx/libSceLibcInternal/CMakeLists.txt core/libs/prx/libSceLibcInternal/CxxRuntimeForwards.cpp core/libs/prx/libSceLibcInternal/InventoryExports6.cpp core/libs/prx/libSceLibcInternal/include/Api.hpp core/libs/tests/GuestLibcInternalCxxForwards.cpp docs/dev/debt/libSceLibcInternal.mdNo changed Python test module in tools/ can be run as a no-build base-source control.Raw precheck stderr for the missing local helper files:
Hosted check output at review time:
Results
Negative control
Not run: the new C++ test requires a built target. No negative-control result is claimed.
Findings
Blocking
The wrappers delegate both sized nothrow deletes to
libc's delete exports and returnlibc'siostream_categoryobject. The PR's debt entry says it has not been verified that the console'slibSceLibcInternaluses the same application heap or shares that category object. The host test confirms the chosen forwarding behavior, not that it matches the console ABI. The repository rule says to throw and record debt when general behavior is unknown. Please provide commit-pinned console or equivalent ABI evidence for these cross-library assumptions, or keep the unverified exports throwing and record the gap until that evidence is available.Non-blocking
None.
Sources
Not verified
No build, C++ runtime test, Linux/macOS/Windows run, or PS5-console comparison was performed by me. The Windows test and export results in the PR description are author-reported. Hosted checks were pending at the time of review.
To get this to a good state
Add evidence establishing the console's heap and category-object behavior, or restore throwing implementations for the unverified exports and retain the debt entry. I will re-run the same no-build checks and review the exact new head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T19:35:31Z.
Review: COMMENTED
Reviewed — no blocking findings
The duplicate declaration that MarcZX10's earlier review found is fixed, and the three forwards match the libc functions they call. Approval waits for the macOS jobs, which were queued at review time.
What I ran
9cc66f0e5d26c6ff813c0b63902979f5054b97a8(two commits on top of basef2d874c1fd:92b77cf736, then9cc66f0e5d). 7 files, +125/-21. I read the whole diff.tools/nid_names.pycompute_nidon its mangled name:_ZdlPvmRKSt9nothrow_t→7VPIYFpwU2A,_ZdaPvmRKSt9nothrow_t→7lCihI18N9I,_ZSt17iostream_categoryv→V23qt24VPVs, all three match the NIDs they export._ZdlPvm_nid_postfixand_ZdaPvm_nid_postfixcallApplicationHeapFree_nid_no_patchfor non-null pointers (StdioExtras.cpplines 141-147), which is the release the test counts._ZSt17iostream_categoryv_nid_postfixreturns&std::iostream_category()(CxxAbiSupport.cppline 104).libc/include/Api.hppline 152). At92b77cf736a second local declaration sat inCxxRuntimeForwards.cpp; the fix commit removed it.InventoryExports6.cpp, so no NID is exported twice in the library.Results
add_test_executablein CMake; the heuristic flag is a false positiveCommands and unedited precheck output
Commands:
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14796 --output-dir <scratch>/precheck/14796(report.md in that directory).tools/nid_names.pycompute_nidon the three mangled names, compared with the explicitAPS5_EXPORTstrings.gh api repos/boykopovar/AnyPS5/commits/9cc66f0e5d26c6ff813c0b63902979f5054b97a8/check-runs.Precheck table (unedited):
The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check f2d874c1fdccf781c0fa5d86619bb5dd8894b958...9cc66f0e5d26c6ff813c0b63902979f5054b97a8/marc/Conlyse-VIEJO/.venv/bin/python3 tools/check_conventions.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head 9cc66f0e5d26c6ff813c0b63902979f5054b97a8 --title feat(libSceLibcInternal): forward the sized nothrow deletes and iostream_category to libc --body /dev/shm/reviewer-run/precheck/14796/pr-body.md/marc/Conlyse-VIEJO/.venv/bin/python3 tools/pr_abi_audit.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head 9cc66f0e5d26c6ff813c0b63902979f5054b97a8 --jsonNo changed Python implementation files.No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.No changed test_*.py files./marc/Conlyse-VIEJO/.venv/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14796 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14796/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./marc/Conlyse-VIEJO/.venv/bin/python3 /dev/shm/reviewer-run/precheck/14796/head-9cc66f0e5d26-23cc442f/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14796/head-9cc66f0e5d26-23cc442f --json core/libs/prx/libSceLibcInternal/CMakeLists.txt core/libs/prx/libSceLibcInternal/CxxRuntimeForwards.cpp core/libs/prx/libSceLibcInternal/InventoryExports6.cpp core/libs/prx/libSceLibcInternal/include/Api.hpp core/libs/prx/libc/include/Api.hpp core/libs/tests/GuestLibcInternalCxxForwards.cpp docs/dev/debt/libSceLibcInternal.mdNo changed Python test module in tools/ can be run as a no-build base-source control.Negative control
Not run here. The test needs a build.
Findings
Blocking
None.
Non-blocking
_ZSt17iostream_categoryv_nid_postfixis declared and defined withoutAPS5_VABI(libc/include/Api.hppline 152,CxxAbiSupport.cppline 104), while the guest export that calls it isAPS5_VABI(CxxRuntimeForwards.cppline 20). The call passes no arguments, so the result is the same, but the two declarations use different conventions. Matching them would remove the question.libSceLibcInternalshares libc's application heap and itsiostream_categoryobject. The debt entry records both as unverified. Whether to ship on that assumption is a maintainer decision.GuestLibcInternalCxxForwards.cppis flagged by the test-quality heuristic only because its CMake registration uses a full path; the test is registered.Sources
github.com/boykopovar/AnyPS5@9cc66f0e5d/core/libs/prx/libSceLibcInternal/CxxRuntimeForwards.cpp (L1-L25)github.com/boykopovar/AnyPS5@9cc66f0e5d/core/libs/prx/libc/include/Api.hpp (L152)github.com/boykopovar/AnyPS5@9cc66f0e5d/core/libs/prx/libc/src/StdioExtras.cpp (L141-L147)github.com/boykopovar/AnyPS5@9cc66f0e5d/core/libs/tests/GuestLibcInternalCxxForwards.cppgithub.com/boykopovar/AnyPS5@9cc66f0e5d/docs/dev/debt/libSceLibcInternal.mdNot verified
libSceLibcInternal.sprxwas not read; the heap and category assumptions are unverified, as the debt entry says.To get this to a good state
APS5_VABIconvention on the category declaration. Approval waits for the macOS jobs on this head.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-06T20:01:52Z.
Review: CHANGES_REQUESTED
Thanks, the NIDs, signatures, the two sized nothrow deletes, the test and the debt entry check out. One blocker:
core/libs/prx/libSceLibcInternal/CxxRuntimeForwards.cpp:21:sceLibcInternalIostreamCategory_nid_no_patchcalls_ZSt17iostream_categoryv_nid_postfix. After NID patching that call becomes an import ofV23qt24VPVs, whichlibSceLibcInternalalso exports, so on Linux it can bind to the forwarder itself and recurse forever (reported by @GiannisG1 above; #13730'spatched_self_importsreproduces it).guest_libc_internal_cxx_forwardslinks the libraries directly, so it cannot see it. The two deletes are not affected (lYDzBVE5mZsandFOt55ZNaVJkdiffer from the exported NIDs).Fix: have the forwarder not go through the patched import, e.g. move the body into a
_nid_no_patchfunction inlibcthat both libc's export and this forwarder call (what #13730 does for the other eight), or return&std::iostream_category()directly. Please keep the test comparing against libc's object.Once that is changed this can merge.