Repository navigation
feat(libSceLibcInternal): implement the messages facet members - #21170
Merged
Merged
Conversation
messages<char> and messages<wchar_t> open, get and close call the facet's do_open, do_get and do_close through its vtable, and do_get returns a copy of the default string, as the Microsoft STL xlocmes does. The copy follows basic_string's _Construct_lv_contents on the guest string. libc's exported messages<char> vtable now holds the destructors, _Incref/_Decref and do_open (-1), do_get and do_close, as for collate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 tasks done
PrivacyOnion
approved these changes
Nov 16, 2026
PrivacyOnion
left a comment
Contributor
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 0bd059835e:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_libc_internal_messages_tests,guest_locale_testsbuilt cleanly. - CTest (
guest_locale,guest_libc_internal_messages):1/2 Test #1324: guest_locale ..................... Passed 0.03 sec 2/2 Test #4002: guest_libc_internal_messages ..... Passed 0.03 sec 100% tests passed, 0 tests failed out of 2 - Negative control: with
core/libs/prx/libSceLibcInternal/Export.cpp,core/libs/prx/libSceLibcInternal/include/Api.hpp,core/libs/prx/libSceLibcInternal/include/PendingExports.hpp,core/libs/prx/libc/include/GuestLocale.hpp,core/libs/prx/libc/src/LocaleSupport.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass. - Code reading:
- Verified MessagesVtable layout and static_asserts in core/libs/prx/libc/include/GuestLocale.hpp (open at 0x20, get at 0x28, close at 0x30, sizeof == 0x38) and _ZTVSt8messagesIcE_nid_postfix population in core/libs/prx/libc/src/LocaleSupport.cpp.
- Checked MessagesSlot null facet, null vtable, and null slot validation in core/libs/prx/libSceLibcInternal/Export.cpp for char and wchar_t messages::get, open, and close exports.
- Verified CopyStringUnits in core/libs/prx/libc/src/LocaleSupport.cpp for null pointer checks, maxSize bounds, inline vs heap storage selection, SSO 16-byte buffer copy, and heap allocation with (capacity + 1) * unit and (size + 1) * unit copy.
- Checked ABI signatures, return types, and parameter ordering across PendingExports.hpp, Api.hpp, Export.cpp, and GuestLocale.hpp, as well as LP64/LLP64 type safety.
- Confirmed AGENTS.md compliance, technical debt fragment documentation in docs/dev/debt/changes/feat-messages-facet.md, and CTest/convention gate results.
Looks Good To Me
Progress report (ff36fea → 0bd0598)📈 System libraries: 41.45% (+0.03%, +11 implemented functions) ✅ 11 implemented
⚪ 2 behaviourally empty (constant return or throw)
Changed libraries (implemented exports)
|
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
libSceLibcInternal's
messages<char>andmessages<wchar_t>get,open,closeanddo_getthrew throughNotImplemented_nid_no_patch, and libc's exportedmessages<char>vtable (_ZTVSt8messagesIcE, NIDFnEnECMJGag, #10158) was nine zeroed slots, so a virtual call through a facet that uses it jumped to address 0. This change follows the Microsoft STLxlocmesfor these.get,openandclose(NIDsXxsPrrWJ52I,U2t+WvMQj8A,EeBQ7253LkE; wideEa+awuQ5Bm8,TPq0HfoACeI,GGoH7e6SZSY) call the facet'sdo_get,do_openanddo_closethrough its vtable and return what they return. The newGuestLocale::MessagesVtableplaces them at 0x20, 0x28 and 0x30 past the vtable pointer, after the two destructors and_Incref/_Decrefthat every facet vtable here starts with;static_asserts pin the offsets.getreturns a string by value, so it takes the result pointer first and the facet second, as thecollatetransformslot already does inGuestLocale.hpp.do_get(NIDsvbgCuYKySLI,UM6rGQxnEMg) ignores the catalog, set and message and returns a copy of the default string. The copy followsbasic_string's copy constructor (_Construct_lv_contents) on the 0x28-byte guest string:wchar_t) copies the whole 16-byte buffer and records capacity 15 (7);size | 15(size | 7) andcapacity + 1elements from the shared guest string allocator, with the terminator copied;_Myptrdoes, so a short string held on the heap is copied inline.messages<char>vtable now holds, in slots 2 to 8, theDestroyCollate,DeleteCollate,RetainFacetandReleaseFacetfunctions thecollate<char>vtable uses (c66f61f), thendo_openreturning -1,do_getmaking the copy above anddo_closedoing nothing. Offset-to-top and typeinfo stay zero, as forcollate.LibcCopyString_nid_no_patchandLibcCopyWideString_nid_no_patch, next to the existingLibcAssignWideCString_nid_no_patch.do_openreturning -1 anddo_closedoing nothing agree with the firmware 13.42 reading behind 40c1005, which answers the existingdo_openanddo_closeexports (NIDsHeBwePMtuFs,rRmMX83UL1E,zSehLdHI0FA,AjkxQBlsOOY). Those four are unchanged.What still throws, and why:
get,openorclosethrowsstd::invalid_argumentwithout calling anything. The console would fault reading through the null pointer.do_get: a null result or default, a default whose capacity says heap but whose pointer is null, and a size abovemax_size()throwstd::invalid_argument.max_size()is assumed to beSIZE_MAX - 1(SIZE_MAX / 2 - 1forwchar_t), as in the existingbasic_stringdebt entry; the console's value was not read. A copy too large to allocate throwsstd::bad_allocfrom the allocator.messages<char>::_Getcat(NID96Ev+CE1luE) and themessagesconstructors still throw; no available source settles their console layout. So nothing in this tree builds amessagesfacet yet; the wrappers run only on facets the title builds, with its own vtable or libc's.messages<wchar_t>vtable is exported, so the wide wrappers run only on a facet whose vtable the title supplies.Debt:
docs/dev/debt/changes/feat-messages-facet.mdremoves the eight "declaration is for import resolution only" entries, adds one Functional entry tolibSceLibcInternal.mdand changes themessages<char> vtableentry inlibc.md. Each entry is under the 1000-character limit.Overlap:
tools/pr_overlap.py --namesbefore starting, for 13messagesnames (the narrow members, destructors,_Getcatand vtable, and the wideget,do_getand vtable): the only open pull request it lists is refactor(prx): name the libSceLibcInternal export aliases the NID databases resolve #17300 (refactor, changes requested), which renames the placeholders to their mangled names without implementing them. feat(libc): implement the std::__sce_v2 messages virtuals #17296 implementsstd::__sce_v2::messages, a different class, under its ownSceV2Messages*names.tools/pr_overlap.py --branch feat/messages-facetexits 2. It reports one conflict, feat(libSceLibcInternal): raise wide basic_string _Xlen/_Xran and ios_base::failure::_Doraise #19359, and eight pull requests it cannot compare because they already conflict withmain. I compared each withgit merge-tree --write-treeagainstmainand against this branch:_Doraiseon the lines directly above themessages<char>::getstub inExport.cppandPendingExports.hpp, so the two hunks touch. Neither changes the other's lines; the resolution keeps both changes.Export.cppand from 2 to 3 inApi.hpp, because it renames the samesceLibcInternalPending4_005to_012functions this branch implements. The stubs are replaced in place to keep that small.mainin the files this branch changes, with the same number of hunks as with this branch. feat(libSceLibcInternal): implement the msun trigonometric kernels #13778 conflicts withmainonly in files this branch does not change.Not in this PR:
messagesconstructors and_Getcat.messages<wchar_t>vtable export.numpunct<char>,codecvt<wchar_t>and others). feat(libc): wire the codecvt<wchar_t,char> facet vtable #11172 wirescodecvt<wchar_t>.Tested
Fedora 44 x86-64, GCC 16.2.1, GNU ld 2.46.1, CMake 4.3.0, Ninja 1.13.2, Release with
-DBUILD_TESTING=ON, onmainat ff36fea. I ran no title, homebrew or console, because I have none. Nothing was built or run on Windows or macOS.cmake --build buildbuilt the whole tree.tools/select_tests.py(BUILD.md, "Selective test builds") was 5594 tests, because libc and libSceLibcInternal are linked into almost every test. 5591 passed and 3 failed:agc_driver_image_table_packed_guards,audio_out2_port_layoutsandguest_http. All three fail the same way onmainat 2454441, the previous base of this branch: I checked outmainin the same tree, rebuilt their executables and ran each alone. The same three failed with this branch on that base.guest_httpandaudio_out2_port_layoutsabort, andagc_driver_image_table_packed_guardslogs "invalid format" image-table write-backs. 59 tests skipped themselves: 57 AGC and VideoOut tests,guest_environment_binding_unloadandguest_net_raw_protocol. In an earlier run of the selection, two rebases back,guest_kernel_stack_protectalso aborted once under-j 16. It passed when run alone and in the final run.guest_libc_internal_messages(new):get,openandcloseexports calls only its own slot of a recording vtable, passes the result, facet, catalog, set, message, default, name and locale through unchanged, and returns the slot's result;do_getforcharandwchar_t:size | 15orsize | 7;wchar_t) gets aligned storage from the large-allocation path;_ZTVSt8messagesIcE:openreturns -1,getcopies the default,closereturns;guest_locale(extended): libc'smessages<char>vtable has zero offset-to-top and typeinfo and non-null slots 2 to 8. It checks destroy, retain and release,openreturning -1,close, a short and a longget(capacitylength | 15, new storage, same bytes), a null default throwing, and the deleting destructor on a facet fromoperator new.size + 1elements into the inline buffer;do_openreturning 0;do_closeslot;getswapping set and message;do_getusing the narrow layout.tools/check_conventions.py --base origin/mainreports "All conventions checks passed." With--titleand--bodyset to this title and body, it also passes.tools/debt_fold.py --checkpasses.tools/pr_overlap.py --branch feat/messages-facet: see Overlap above.Sources
Microsoft STL links are to
219514876ea86491de191ceaa88632616bbc0f19, the first public release, the pin thestd::_MP_*entry inlibSceLibcInternal.mdalready uses.open,getandclosecalldo_open,do_getanddo_closeand return their resultstl/inc/xlocmeslines 38-49do_openreturns -1,do_getreturns the default,do_closedoes nothingstl/inc/xlocmeslines 84-94;do_openanddo_closealso agree with the firmware 13.42 reading in 40c1005do_open,do_get,do_close, in declaration orderstl/inc/xlocmeslines 79-94; the facet's_Incref/_Decrefvirtuals instl/inc/xlocalelines 136-146; the first four slots as in the existingGuestLocale::FacetVtableand thecollate<char>vtable (c66f61f)_BUF_SIZEcopies_BUF_SIZEelements and sets capacity_BUF_SIZE - 1; otherwise capacitymin(size | _ALLOC_MASK, max_size()),capacity + 1elements allocated andsize + 1copiedstl/inc/xstringlines 2461-2479_BUF_SIZE16 / 8 and_ALLOC_MASK15 / 7 for 1- and 2-byte elementsstl/inc/xstringlines 2040-2046_BUF_SIZEstl/inc/xstringlines 2047-2066 (_Myptr,_Large_string_engaged)GuestLocale::Stringincore/libs/prx/libc/include/GuestLocale.hpp;GuestStringStorage::Allocateincore/libs/prx/libc/GuestStringStorage.hppst_size) in thelibc.prxbundled with PPSA26344Checklist
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)