feat(libc): throw std::__sce_v2::filesystem::filesystem_error from _Xfilesystem_error #15486
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15486"
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 SwetabhSingh17 on 2026-11-03T14:55:17Z.
What
Implement
std::__sce_v2::filesystem::_Xfilesystem_errorin libc:_ZNSt8__sce_v210filesystem18_Xfilesystem_errorEPKcNS_10error_codeE_nid_postfix_ZNSt8__sce_v210filesystem18_Xfilesystem_errorEPKcRKNS0_4pathENS_10error_codeE_nid_postfixFollowing the 0x90-byte object layout with code at 0x30, paths at 0x40 and 0x68, and string representation assumed from the unversioned module:
SceV2FilesystemErrorType("NSt8__sce_v210filesystem16filesystem_errorE") with base&SceV2::SystemErrorTypeandSceV2FilesystemErrorvtable.SystemErrorObject baseinsideFilesystemErrorObjectand updateThrowFilesystemErrorto initializeobject->base.code = code;at offset 16 (theSystemErrorObjectcode location) alongside preservingobject->code = code;at offset 0x30 for both versioned and unversioned throwers.std::invalid_argumentif message, error category, or path is null.core/libs/tests/GuestFilesystemError.cpp, verifying catches asstd::__sce_v2::system_errorand access tocode()with valid categories.docs/dev/debt/libc.md: restore theVersioned std::__sce_v2::filesystem primitivesentry linkingVersionedFilesystem.cppwithout the resolved_Xfilesystem_errorsentence, record the unverified sce_v2 layout in a dedicated entry linkingStandardExceptions.cpp, and update the unversioned entry for the code-at-16 initialization.Tested
python3 tools/check_conventions.py --base origin/main(clean, 0 warnings)python3 core/libs/tests/test_public_headers.py --audit-only(verified umbrella coverage)GuestFilesystemError.cpp: addedCheckSceV2Messages(),CheckSceV2Paths(),CheckSceV2NullArguments(), andCheckSceV2SystemErrorBase()validating standard catch matching, type name,code(), category names, and pathsChecklist
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 XairRrR on 2026-11-03T15:30:10Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The new
std::__sce_v2::filesystem::_Xfilesystem_errorthrowers build, and the focused tests pass and catch a missing basecode(). However, the sce_v2 object layout cites no source, and the technical debt changes break the project's rules for debt entries.What I ran
Head
7baa0af1dfa18df574b95db512cd96431993aecc,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged with--no-ffintof8a44a9c40e8e79b57145e7ab30c314f3e0c94e3(Release, GCC 14.2.0, Ninja, Debian 13 VM).Results
git diff --checkcheck_conventions.pymainguest_filesystem_error,guest_sce_v2_filesystem,guest_sce_v2_filesystem_calls,guest_sce_v2_exceptionsNegative control
main:GuestFilesystemError.cppdoes not compile, because the old declarations of the two sce_v2 exports take no arguments (too many arguments to function ... _Xfilesystem_errorEPKcNS_10error_codeE_nid_postfix()).object->base.code = code;removed: the test fails as it should.output
After restoring the merged files, the tests pass again and
git status --porcelainis empty.Findings
Blocking
The sce_v2 layout and behaviour cite no source, and the debt entry does not say so.
core/libs/prx/libc/src/exception/StandardExceptions.cpp:805-806and:834-840reuse the 0x90-byte object of the unversioned thrower forstd::__sce_v2::filesystem::filesystem_error:what()built asmessage: category text;std::__sce_v2::filesystem::pathtreated asGuestLocale::String.That unversioned layout was read from the SDK 7.00
libc.prxof PPSA06416 (docs/dev/debt/libc.md:266). The PR names no disassembly of the versioned throwers. The rest of the sce_v2 code was checked against thelibc.prxbundled with PPSA28416, so that source exists. CONTRIBUTING requires behaviour taken from a library to follow the reverse-engineering guide, and a debt entry to state the gap first.The new text at
docs/dev/debt/libc.md:307instead presents the layout as settled.Fix: either check the two exports in a versioned
libc.prxand cite the module, build and offsets, or say in the entry that the sce_v2 layout is assumed from the unversioned module and not verified.The debt entry was rewritten instead of cut, and now links the wrong file. On
main, the entry atdocs/dev/debt/libc.md:307stated an open gap: "The console loops oversceKernelGetdentsitself, as thelibc.prxbundled with PPSA28416 shows, and maps the same errors". The new text drops it, although the PR does not touch_Open_diror_Read_dir.The entry also now links
src/exception/StandardExceptions.cpp, but_Open_dir,_Read_dir,_Close_dir,_Current_getand_Statlive insrc/VersionedFilesystem.cpp(for example_Open_dirat line 104).CONTRIBUTING says that a PR closing a gap "removes its entry, or cuts it to what is still open, instead of rewriting it to describe the corrected behaviour".
Fix:
NotImplementedthrowers and the missingfilesystem_error)._Xfilesystem_errorgaps from finding 1 as a separate entry that linksStandardExceptions.cpp.Non-blocking
The unversioned thrower changed too, but its entry was not updated.
ThrowFilesystemErrornow also writes the code at offset 16 forstd::filesystem::filesystem_error; the bytes there used to be zero. The entry atdocs/dev/debt/libc.md:266still says the object'ssystem_errorpart "does not match this library's 32-bytestd::system_error, whose code is at 16", which is now partly false.The change looks reasonable: this library's message is a pointer at 0x08, so offset 16 is free. Still, the description should mention it, and the entry should be cut to what is still open: the module keeps a
std::stringup to 0x30.The PR description is slightly inaccurate. It says the change follows "the unversioned ... layout", but it also changes that layout (see the previous point).
Not verified
libc.prx: I have no module to disassemble here.To get this to a good state
Versioned std::__sce_v2::filesystem primitivesentry with its link toVersionedFilesystem.cpp. Remove only the sentence this PR resolves, and put the_Xfilesystem_errorgaps in their own entry that linksStandardExceptions.cpp.std::filesystem::_Xfilesystem_errorentry so it matches the new code-at-16 behaviour, and mention that change in the description.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T15:44:00Z.
Review: APPROVED
Re-checked — approved
The new commit changes only
docs/dev/debt/libc.md, and the PR description was edited. Both blocking findings and both non-blocking findings from my last review are resolved. The code and tests are unchanged and still pass.What changed since my last review
git diff 7baa0af1df 97efb9ccaa --statshows one file:docs/dev/debt/libc.md(+3 −2).StandardExceptions.cpp,VersionedFilesystem.cpp,Api.hppandGuestFilesystemError.cppare the same as in7baa0af1df.What I ran
Head
97efb9ccaa0fd0fffd0456e2008e0445e098e5f4,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged with--no-ffinto72754688cdd0f1410a1b8daf59d70a118fc5f094(Release, GCC 14.2.0, Ninja, Debian 13 VM).git diff --checkcheck_conventions.pymain.guest_net_ctlwas skipped for a reasontools/check_skips.pydoes not expect, and it is skipped onmaintoo.guest_sce_v2_exceptions,guest_filesystem_error,guest_sce_v2_filesystem,guest_sce_v2_filesystem_callsmaindiffexit 0)I did not repeat the negative control. The test and production files are identical to the commit I reviewed last time. There, restoring the production files from
mainbroke the test build, and removing onlyobject->base.code = code;madeguest_filesystem_errorfail.Previous findings
docs/dev/debt/libc.md:308puts the gap first. It says the 0x90-byte layout, the code at 0x30, the paths at 0x40 and 0x68, and the string representation are assumed from the unversioned module, without console verification.docs/dev/debt/libc.md:307again linksVersionedFilesystem.cpp. It is the same as the entry onmainwithout its last sentence about theNotImplementedthrowers (diff above), so thesceKernelGetdentsgap is back. The_Xfilesystem_errorgaps now have their own entry, which linksStandardExceptions.cpp.docs/dev/debt/libc.md:266no longer says thesystem_errorpart does not match. It now says the code at 16 is initialized, and keeps the open gap: the module keeps astd::stringup to 0x30.New findings
Blocking
None.
Non-blocking
None.
Not verified
libc.prx. It is now recorded as unverified technical debt.