feat(libc): throw std::filesystem::filesystem_error from _Xfilesystem_error as the console's libc does #11504
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11504"
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 verusferro on 2026-10-26T17:34:32Z.
What
Both
std::filesystem::_Xfilesystem_erroroverloads that libSceLibcInternal exports,B0CeIhQty7Y(message,error_code) andC6-7Mo5WbwU(message,path,error_code), threwNotImplemented. The SDK's<filesystem>calls them when an operation fails, so a title stopped there instead of getting astd::filesystem::filesystem_errorit can catch. They now throw that exception as the SDK 7.00libc.prxthat PPSA06416 ships insce_module/does (0x80270 and 0x80490), read from its disassembly (REVERSE_ENGINEERING, source 2):system_errorpart with Dinkumware's_Makestr(0x14300): the message, then": "if the message is not empty, then the text fromcode.category().message(code.value()), called through the category's vtable.path1(0x40) is a copy of the path, or empty for the first overload, andpath2(0x68) is empty.runtime_error::whatandsystem_error::_Doraise. The type info (0x10dc90) is namedNSt10filesystem16filesystem_errorE, withstd::system_erroras its base. The module does not export it, so a title catches the exception through its own copy of the type info, which this library's catch matching compares by name.The code is in libc, next to the other exception types, as
srandomdevand thefenvfunctions of libSceLibcInternal are. The two stubs leave libSceLibcInternal, so both NIDs resolve to libc.code(),path1()andpath2()are inline in the SDK headers, so those offsets follow the module. Bytes 0x08 to 0x30 belong toruntime_errorand are private. They hold this library's message pointer, as all of itsruntime_errors do, so its exportedruntime_errorcopy andwhatfunctions still work on the object. The module's ownstd::system_erroris 0x40 bytes with the code at 0x30, while this library'sstd::system_error(from_Throw_Cpp_error) is 32 bytes with the code at 16. This PR leaves that alone; the new debt entry records it.AllocateStringStoragemoves out of LocaleSupport's anonymous namespace intoGuestLocale, next to a newReleaseStringStorage, which frees with the console's large-allocation rule. The path copies need both, and so does a guest category's message string. A null message, path or category throwsstd::invalid_argument, where the module dereferences it.#10989 adds the versioned
std::__sce_v2::filesystem::_Xfilesystem_errorpair as throwing stubs. They could reuseThrowFilesystemErrorif the versioned type has the same layout, which I have not checked. The two PRs merge without conflicts.Tested
Ubuntu 24.04 (WSL2) x86-64, GCC 13.3, Release, full build with
BUILD_TESTING=ON, onmain2227f13661:New
guest_filesystem_errortest, which uses the guest catch frame ofguest_sce_v2_exceptions:std::system_error, and by name asfilesystem_error;what()with and without a message, and the code value and category at 0x30;path1copies of 5, 26 and 4,200 bytes (inline, heap and large allocation), and thatpath2is empty;Always adding
": "fails it.ctest -R '^(guest_filesystem_error|guest_sce_v2_exceptions|guest_future_category|guest_locale|guest_libc_filesystem|patched_libraries|conventions_unknown_nids)$': 7/7 pass.guest_future_categorycovers #11241'sstd::future_error, whichmainadded toStandardExceptions.cppsince this PR was opened.The patched
libc.prxexportsB0CeIhQty7YandC6-7Mo5WbwU, and the patchedlibSceLibcInternal.prxno longer does.tools/progress.py: +2 implemented. libSceLibcInternal goes from 72/76 to 72/74 (94.74% to 97.30%), libc from 1419/1436 to 1421/1438.python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branch feat/libc-xfilesystem-error: two conflicts and no same exports. #10749 adds itssiginterruptentry right after the libSceLibcInternal debt entry this PR removes; its author accepts either order. #11773 movesAssignCString, whoseAllocateStringStoragecall this PR qualifies withGuestLocale::; I asked to go first. Of the pull requests it could not compare, #9526 and #7081 change other parts ofLocaleSupport.cpp.Windows: ycbuzi ran
guest_filesystem_erroron the previous head66140677ecwith WinLibs GCC 15.2.0; it passed. Not tested: macOS, a title that throwsfilesystem_error, a console 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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T17:50:32Z.
Review: CHANGES_REQUESTED
The implementation and focused test report are substantial, but this branch is based on
349055c1cd5742185a57eb71b3b2e4ab9b6d1cadand is 82 commits behind currentmain(88795ed448).CONTRIBUTING.mdrequires branches to stay up to date. Please rebase/sync and rerun the focused libc tests on the updated branch before merge. My changed-path comparison found onlydocs/dev/debt/libc.mdoverlapping intervening main changes; I found no specific defect in the implementation during this pass.Local conventions and
git show --checkpass. The PR reports a full WSL2 build and its six focused tests passing. Current hosted register-context and ASan checks pass; product Linux/Windows jobs are skipped, and two macOS relinker jobs are still pending. Changes requested for branch freshness and updated validation, not for a demonstrated code defect.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T18:06:21Z.
Review: DISMISSED
REQUEST_CHANGES - CONTRIBUTING.md, "Branches and pull requests": keep the branch up to date with main.
Reviewed
268beae7d9dbagainst88795ed44801. The PR merge base is349055c1cd57, leaving this branch 82 commits behind the pinned main base. The hosted Linux and Windows product jobs were skipped, so they did not build the change merged into current main.Validation: MinGW GCC 15.3 Release built the affected libc and test;
guest_filesystem_errorandguest_sce_v2_exceptionspassed (2/2). Added path/category cases below and at the 0x1000 allocation threshold passed; a>=to>negative control failed with "guest allocation is not registered."Please sync/rebase to current main and rerun the focused libc tests on that head, then request re-review. The local build used PR-head files over cached sources, not a full checkout of the pinned merge base. I found no production-code defect in the reviewed patch.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T18:15:42Z.
Review: APPROVED
The branch is now current with
main(88795ed448; 0 behind, 1 ahead), and the author reports the focusedguest_filesystem_error,guest_sce_v2_exceptions,guest_locale,guest_libc_filesystem,patched_librariesandconventions_unknown_nidstests passing on the updated head. The implementation/test patch is unchanged by the sync. The six cases cover both exception layouts, message/path storage including large allocations, guest category messages, catches bysystem_errorand type name, and null arguments. Local conventions andgit show --checkpass.The PS5 behavior is backed by the shipped SDK module disassembly described in the PR; no title run or console result is claimed. Hosted product Linux/Windows jobs are skipped; register-context and ASan checks pass, while several macOS jobs remain pending. With the freshness and retest request addressed, I found no remaining blocker and approve.
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-28T15:41:07Z.
Review: COMMENTED
Re-reviewed
778c4a74ec4c86e29c48bd3766745debe86a91f5. The earlier sync-and-retest request has been addressed. The filesystem-error implementation and its fixture are unchanged from my earlier review; the branch now uses base2227f13661. The 14 subsequent commits on pinned main750cf6cf48touch none of this PR's changed files, and GitHub reports a clean merge. I found no new production-code defect in this pass.Validation: Windows, GCC 15.3, Release, isolated pinned checkouts: 6/6 focused CTests passed on the head (filesystem-error, versioned exceptions, future-category, locale, libc-filesystem, and the conventions test suite); the baseline passed its five corresponding CTests and has no filesystem-error target. Additional path cases cover inline/heap transitions, the 0x1000 allocation boundary, empty paths and embedded NULs; guest-category message boundary cases also pass. An unconditional-separator negative control fails the empty-message assertion; restoring the original sources passes. The direct conventions check passes.
Using the freshly built NID patcher on copies of the two built libraries,
objdumpconfirms both NIDs are exported by patched libc and absent from patched libSceLibcInternal.The current-head hosted Build is still queued, so this is a COMMENT pending CI completion. These are focused Windows checks, not a full product build, a current-main merge execution, or a console/title run. The documented ABI limitations and declared merge ordering remain relevant.