feat(libSceLibcInternal): implement numpunct, facet construction and stream runtime #25573
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25573"
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 MertSoylu on 2026-11-22T09:32:05Z.
What
Implements 89 libSceLibcInternal exports from the
libc.prxbundled with PPSA21564, inspected statically:numpunct<wchar_t>construction,_Initand destructors (Punctuation.cpp). Separators are those of the C locale, the only locale_Locinfoholds, not the globallocaleconv._Initand_Getcatforcollate,num_get,num_put<char>,money_get,money_put,time_get,time_putandmessages. Alsolocale::_Locimpdestruction andC1,locale::empty,locale::~locale, the_Locinfoname constructors and_Addcats, thectype<wchar_t>destructors, thenum_put<char>/money_put_Put/_Rephelpers andDinkum::codecvt::_Cvt_check(FacetConstruction.cpp).~_Locimpreleases the system lock on every path, including when a facet destructor throws.num_getdo_get(bool),num_get<wchar_t>::do_get(void*)and_Getifld(NumGet.cpp).StreamRuntime.cpp): the_System_error_category/_Iostream_error_categorymembers,_Debug_message, andbasic_filebufsync,pbackfailand_Endwrite.std::_sceLibcLocinfo, the remaining inet helpers andbasic_string<char>::_Copy.libSceLibcInternal coverage goes from 60.14% to 68.06% (676 to 765 of 1124) per
tools/progress.pyagainst currentmain.Functions also implemented by other open PRs are left out of this one: moneypunct/_Mpunct (#18135), the wide num_put constructors and
_Getcat(#24884),__kernel_*(#13778),istreambuf_iterator::equal(#23809), widetime_put::_Init(#24899) andnum_get<char>::do_get(void*)(#24748). After the review, the exports of #14834 (error-class deleting destructors), #19602 (std::_Mutex), #19767 (_Set_raise_handler), #21930 (numpunct<char>_Init,C1,C2,D0,D1,D2), #24526 (facet D0 destructors ofcollate<wchar_t>,num_get,num_put<char>,money_get,money_put<char>), #22370 (_LocimpC2and_LocinfoC1), #24880 (widemoney_get/money_put), #24942 (messages_Getcat) and #25111 (do_scan_is) are left out too. Known gaps are recorded in the debt fragment.Tested
Windows 11, MinGW-w64 GCC:
ctest -R guest_libc_internalpasses (90/90). That includes the newguest_libc_internal_punctuation,guest_libc_internal_facet_construction,guest_libc_internal_stream_runtimeandguest_libc_internal_locale_nametests.tools/check_conventions.py --base upstream/mainandtools/debt_fold.py --checkare clean. Not run on a console or in a title.Checklist
main; no other open PR implements the same functions (pr_overlap.py --branchreports no shared export; the file overlaps it lists are neighbouring stub lines)NotImplemented_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 PrivacyOnion on 2026-11-22T09:48:37Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
99aa237f5a:tools/check_conventions.pypassed.guest_libc_internal_basic_string_tests,guest_libc_internal_facet_construction_tests,guest_libc_internal_locale_name_tests,guest_libc_internal_punctuation_tests,guest_libc_internal_stream_runtime_tests,guest_libc_internal_time_get_fields_testsbuilt cleanly.guest_libc_internal_locale_name,guest_libc_internal_punctuation,guest_libc_internal_stream_runtime,guest_libc_internal_basic_string,guest_libc_internal_time_get_fields,guest_libc_internal_facet_construction):core/libs/prx/libSceLibcInternal/BasicString.cpp,core/libs/prx/libSceLibcInternal/Err.cpp,core/libs/prx/libSceLibcInternal/Export.cpp,core/libs/prx/libSceLibcInternal/InventoryExports.cpp,core/libs/prx/libSceLibcInternal/InventoryExports2.cpp,core/libs/prx/libSceLibcInternal/InventoryExports6.cpp,core/libs/prx/libSceLibcInternal/NumGet.cpp,core/libs/prx/libSceLibcInternal/include/Api.hpp,core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp,core/libs/prx/libSceLibcInternal/include/InventoryExports6.hpp,core/libs/prx/libc/include/Api.hpp,core/libs/prx/libc/include/GuestLocale.hpp,core/libs/prx/libc/src/LocaleSupport.cpp,core/libs/prx/libc/src/exception/StandardExceptions.cpp,core/libs/prx/libSceLibcInternal/FacetConstruction.cpp,core/libs/prx/libSceLibcInternal/LocaleName.cpp,core/libs/prx/libSceLibcInternal/Punctuation.cpp,core/libs/prx/libSceLibcInternal/StreamRuntime.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T10:05:51Z.
Review: COMMENTED
Reviewed — comments
This review covers the prepared diff at head
99aa237f5aad41a3a396dd00085198dea5210b8e; the changed lines and targeted behavior reviewed do not establish a blocking defect, but the full change was not read.What I ran
No build or tests were run. The author reports Windows 11 MinGW-w64 results, which were not independently verified.
Results
Findings
Blocking
None verified in the inspected excerpts.
Non-blocking
Not verified
The complete changed-line set was not read. In particular, the implementation and tests in
FacetConstruction.cpp,NumGet.cpp,Punctuation.cpp,StreamRuntime.cpp, and the other changed files were not fully reviewed.files.jsonwas not available as a review-folder document; the changed-file inventory was obtained from the review folder listing. No tests or builds were run, and console/title behavior was not verified.To get this to a good state
Nothing is required. Optional: complete a full review of all changed lines and independently run the reported checks.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-22T12:21:18Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
21a25f8972:tools/check_conventions.pypassed.guest_libc_internal_basic_string_tests,guest_libc_internal_facet_construction_tests,guest_libc_internal_locale_name_tests,guest_libc_internal_punctuation_tests,guest_libc_internal_stream_runtime_tests,guest_libc_internal_time_get_fields_testsbuilt cleanly.guest_libc_internal_locale_name,guest_libc_internal_punctuation,guest_libc_internal_stream_runtime,guest_libc_internal_basic_string,guest_libc_internal_time_get_fields,guest_libc_internal_facet_construction):core/libs/prx/libSceLibcInternal/BasicString.cpp,core/libs/prx/libSceLibcInternal/Err.cpp,core/libs/prx/libSceLibcInternal/Export.cpp,core/libs/prx/libSceLibcInternal/InventoryExports.cpp,core/libs/prx/libSceLibcInternal/InventoryExports2.cpp,core/libs/prx/libSceLibcInternal/InventoryExports6.cpp,core/libs/prx/libSceLibcInternal/NumGet.cpp,core/libs/prx/libSceLibcInternal/include/Api.hpp,core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp,core/libs/prx/libSceLibcInternal/include/InventoryExports6.hpp,core/libs/prx/libc/include/GuestLocale.hpp,core/libs/prx/libc/src/LocaleSupport.cpp,core/libs/prx/libSceLibcInternal/FacetConstruction.cpp,core/libs/prx/libSceLibcInternal/LocaleName.cpp,core/libs/prx/libSceLibcInternal/Punctuation.cpp,core/libs/prx/libSceLibcInternal/StreamRuntime.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T12:30:18Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: repair the category 6 messages facet construction so its allocated object has the correct size and initialized vtable.
What I ran
21a25f8972e43aeaa62e9860a100a5c464220637; no build or test commands were run.ctest -R guest_libc_internalpassing 90/90; this was not independently run.repo_read.py.Results
Findings
Blocking
core/libs/prx/libSceLibcInternal/FacetConstruction.cpp:521:MessagesGetcatallocates onlyFacetObjectSize(0x10) bytes, then the messages constructors initialize a larger facet and*facetexposes that allocation as a messages facet. The facet’s derived storage is consequently out of bounds; for the wide messages facet, the constructor initializes aTimeInfopayload far larger than 0x10 bytes. Allocate the appropriate concrete facet size for each instantiation before constructing it.Non-blocking
None.
Not verified
dist/,build/, and SVG files;files.jsonwas not available through the review reader. No claim is made about excluded content.To get this to a good state
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T15:27:15Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected source does not show a verified blocking defect, but this review is incomplete and does not justify approval.
What I ran
Inspected the prepared PR bundle and selected source and test files at head
3760fdbd0ef91427644e97a2a8113d25e62bcfb7using the pinnedrepo_read.pyreader. No tests or builds were run.Results
Findings
Blocking
None verified in the inspected portions.
Non-blocking
None.
Not verified
Read:
description.md,commits.md,manifest.json,diff.patch; source portions ofBasicString.cpp,FacetConstruction.cpp,LocaleName.cpp,NumGet.cpp,Punctuation.cpp, andStreamRuntime.cpp; portions ofGuestLibcInternalFacetConstruction.cppandGuestLibcInternalStreamRuntime.cpp; and the changed-file listing.Not read in full: the changed files above, the remaining changed source and test files, and
files.json. The manifest lists 28 changed repository files, and the listing marks all 28 as included. Consequently, this review does not verify every changed file or every changed hunk. Tests reported in the PR description were not run by this review.To get this to a good state
Nothing is required. Optional: complete review of the unread changed files and run the documented tests before relying on this review for a merge decision.
Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-22T16:24:36Z.
Review: COMMENTED
Review: ✅ matches the firmware where checked; the new
~_Locimpreleases facets that main's_Addfacnever retainedBasis: code read, and the exports compared with the disassembly of a retail
libc.prxbuilt from the same Dinkumware source (found by NID)Checked
_LocinfoC2/C1/_Addcats(0x87db0, 0x8a2e0, 0x87ed0): 0xb8-byte object, name at 0xa8, classic name at 0xb0._sceLibcLocinfo(0x87f20): accepts only "" and "C"._LocimpC1Eb,locale::empty,~localeand~_Locimp(0x8a160, 0x88200, 0x84790, 0x8a1a0).money_get<char>::_Getcat(0x8d200).time_get<char>(size_t)(0x99600).collate<wchar_t>_Initand C2 (0x9cce0, 0x9cc20).numpunct<wchar_t>_Initand D2 (0xa2880, 0xa2ba0).ctype<wchar_t>D1 (0x8a990)._Cvt_check(0xc8120): really an emptyret, so not a made-up success.num_get::do_get(void*)(0xa6b20).money_put<char>::_Put(0x91100).basic_filebuf::pbackfail(0xb5f10)._System_error_category::default_error_condition(0x163d0)._Debug_message(0x81f30).Findings
FacetConstruction.cpp:583-586:~_Locimpreleases every facet and deletes the ones whose count reaches zero. That matches the firmware, but only because the firmware's_Locimp::_Addfac(0x877a0) retains the new facet and releases the one it replaces. Main's_Addfac(libc/src/LocaleSupport.cpp:2457) just stores the pointer. Now thatlocale::empty()builds a real_Locimpwith the PR's vtable, the sequenceempty()→_Addfac→ destroy either wraps the count of a facet created with refs 0 (a leak) or deletes a caller-owned facet created with refs 1 (a double free later). Make_Addfacretain and release as the firmware does, or record the gap.ScanChunk(:29),DeleteObject(:265, an unused function in an anonymous namespace),IteratorHasInput/IteratorsEqual(:286-307).GuestLibcInternalTimeGetFields.cppdrops the checks that widetime_put::_Init(ZolDcuDSD0Q) still throws. That export is unchanged and stillNotImplemented, so keep those checks; only theInventory_197/198removals are needed.time_put<wchar_t>(const _Locinfo&)(:524-529) copies*_Getptimes()instead of the times ininfo, which is what 0xae970 copies. The result is the same while only "C" is accepted; add it to the fragment.Suggested action: fix 1 (or record it), then merge
AI-assisted review (Claude Code) · head
3760fdbd0e· basemain23b8772462Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T18:15:54Z.
Review: COMMENTED
Reviewed — comments
The prepared change describes a broad libc runtime addition; this review covered selected implementation paths but did not verify the full change or run its checks.
What I ran
No commands were run. I read the prepared description, commit summary, manifest, and selected ranges of the diff and pinned source.
Results
Findings
Blocking
None verified in the portions inspected.
Non-blocking
Not verified
Read:
review/description.md,review/commits.md,review/manifest.json, selected portions ofreview/diff.patch,core/libs/prx/libSceLibcInternal/NumGet.cpp,Punctuation.cpp,StreamRuntime.cpp,FacetConstruction.cpp,BasicString.cpp,LocaleName.cpp,core/libs/prx/libc/src/LocaleSupport.cpp, and selected test code inGuestLibcInternalFacetConstruction.cppandGuestLibcInternalStreamRuntime.cpp.Not read in full: the remaining changed files listed in the manifest, including the complete test suite, headers, export and inventory changes, CMake changes, and debt fragment. No tests, build, or convention checks were run. The PR description's test and check results are author-reported.
To get this to a good state
Nothing is required. Optional: complete the review of the remaining changed files and run the reported checks against this head.
Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-22T18:18:15Z.
Review: APPROVED
Review: ✅ re-review: our four points are fixed or recorded
Basis: code read,
3760fdbd0e..3cf6c545de· head3cf6c545deChecked
ScanChunk,DeleteObject,IteratorHasInput,IteratorsEqual) are removed.GuestLibcInternalTimeGetFields.cpp:410checks again that widetime_put::_Initthrows. It is stillNotImplementedatTimeGetFields.cpp:939-941._Addfachere neither retains nor releases, so a facet added to alocale::emptyimplementation is released without being retained. It also records that thetime_put<wchar_t>(const _Locinfo&)constructors copy the C time names, which equal the_Locinfo's while it accepts only "C".numpunct<wchar_t>matches Dinkumware_Init:.,,, empty grouping,true/falselconv(., separator 0)SeparatorsOfignores the_Locinfocontents.Findings
:410passesinfoafter_ZNSt8_LocinfoD1Ev(&info)at:398. It is harmless because the stub ignores its arguments, but it is cleaner before the destructor.Suggested action: merge
AI-assisted review (Claude Code) · head
3cf6c545de· basemain23b8772462Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T14:51:28Z.
Review: COMMENTED
Built the exact punctuation, string, and locale units and ran
GuestLibcInternalPunctuationagainst the existing Linux runtime. The focused fixture passed, including the wide numpunct vtable and punctuation accessors. Merging this head with currentmainconflicts in the export inventories,GuestLocale.hpp, andGuestLibcInternalTimeGetFields.cpp. The fixture covers the punctuation implementation before that reconciliation.AI-assisted: yes.
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.