feat(libc): add ios_base::failure constructors #28897
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28897"
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-12-04T14:45:45Z.
What
Adds three libc exports for
std::ios_base::failure, next to the existingios_base::failuredestructors andwhat:_ZNSt8ios_base7failureC1EPKcRKSt10error_code(2PxU-rB3ixI) and_ZNSt8ios_base7failureC2EPKcRKSt10error_code(xFkYamgQChU):failure(const char*, const error_code&). As in Microsoft STLxiosbase, the object is built throughsystem_error(error_code, const char*), so the message is"<message>: <category message>", or just the category message when the message is empty. This reuses the existing_ZNSt12system_errorC2ESt10error_codePKcpath (LibcExceptionConstructSystemError_nid_no_patch). The constructor then stores theios_base::failurevtable. Theerror_codecomes in by reference, so it arrives as a pointer and is dereferenced. A nullerror_codereference callsGuestFault_nid_no_patch, since the console dereferences it (the input this PR names under the newGuestFaultrule); a null category throwsstd::invalid_argumentfrom the sharedsystem_errorconstructor, as onmain._ZNSt8ios_base7failureC1ERKS0_(igWZiDXnBC0): the copy constructor. It shares the refcounted message and copies the 16-byteerror_code, like the existingsystem_errorcopy constructor.The NIDs are
tools/nid_names.pycompute_nidof each name. I did not check which console module exports these, so this PR adds no libSceLibcInternal forwarders. TheNSt8__sce_v28ios_base7failureEvariants are out of scope. The gap is recorded indocs/dev/debt/changes/feat-libc-ios-failure-constructors.md.Tested
Windows 11, GCC 15.2 (WinLibs UCRT), Ninja Release. The new host test
guest_ios_failure_constructorsis registered incore/libs/prx/libc/tests/cmake/guest_ios_failure_constructors.cmake. It uses a test category whose message is"Invalid argument"and checks:"stream": the type record isNSt8ios_base7failureE,what()isstream: Invalid argument, and the code is{0, 22, &category}. D1 then clears the message."":what()isInvalid argument.what()still works after the source is destroyed, and both messages are null after D1.error_codepointer reachesGuestFault_nid_no_patch(astd::runtime_errornaming the console fault), and a null category throwsstd::invalid_argument.Retested after merging
main87a06f59cf:ctest -R "^(guest_ios_failure_constructors|guest_ampr_cpp_error|guest_filesystem_error)$"passed in each of 3 runs.Red checks:
undefined reference to '_ZNSt8ios_base7failureC1EPKcRKSt10error_code_nid_postfix'.ios_base::failure constructor check 1 failed.tools/check_conventions.py --base origin/mainandtools/debt_fold.py --checkpass. No title or homebrew was run.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T15:10:44Z.
Review: COMMENTED
Reviewed — comments
The changed code and tests support the described behavior, but console exports and behavior have not been verified.
What I ran
Reviewed head
b28afd4581411a187b319c051e01633d7188f301from the prepared diff and file copies. The repository reader search could not run because it tried to write its call log in the read-only review folder. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libc/src/exception/StandardExceptions.cpp:685adds behavior for a console ABI whose implementation and exporting module the author says were not checked. The debt entry records this gap; the implementation is supported by the sharedsystem_errorconstructor and the included host test, but console compatibility remains unverified.Not verified
No tests, build, console run, or console export/module inspection was performed. Read the changed lines and relevant context in all five reviewed files:
core/libs/prx/libc/include/Api.hpp,core/libs/prx/libc/src/exception/StandardExceptions.cpp,core/libs/prx/libc/tests/cmake/guest_ios_failure_constructors.cmake,core/libs/tests/GuestIosFailureConstructors.cpp, anddocs/dev/debt/changes/feat-libc-ios-failure-constructors.md.files.jsonlists no excluded files.To get this to a good state
Nothing is required. Optional: compare the constructors and exporting module with the console libc or libSceLibcInternal module.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T15:47:39Z.
Review: APPROVED
Verified head
b28afd4581on Windows 11 with GCC 15.2, applied to main484b0368d3.guest_ios_failure_constructors: passes.StandardExceptions.cppandApi.hppchanges reverted, the test does not compile, because the constructors are undeclared.Read through:
C1(const char*, const error_code&)builds asystem_error, then switches the vtable toios_base::failure's.C2forwards toC1. The copy constructor uses the sameLibcException::Copyas the other exception copies and copiescode. A nullcodegoes toGuestFault_nid_no_patch, which the debt fragment records.AI-assisted: yes (Claude Code)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.