feat(libSceLibcInternal): implement wide num_put::_Iput #24905
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24905"
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 0x70776c on 2026-11-21T10:16:13Z.
What
Implement
std::num_put<wchar_t>::_Iput(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char*, size_t)(_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_IputES3_RSt8ios_basewPcm, NID4pQ3B1BTMgo) inlibSceLibcInternal:digits, widen throughctype<wchar_t>when present (or unsigned byte widening fallback), applynumpunct<wchar_t>grouping/thousands separators while preserving sign and0x/0Xhex prefixes, and emit padded wide output viaLibcRepeatWideElement_nid_no_patchandLibcPutWideElements_nid_no_patch.digits != nullptrbefore constructing the temporary buffer whencount != 0.core/libs/prx/libSceLibcInternal/tests/WideNumPutField.cpp(guest_libc_internal_wide_num_put_field).docs/dev/debt/changes/feat-libcinternal-wide-num-put-iput.md.Tested
python3 tools/check_conventions.py --base origin/maincmake --build build --target guest_libc_internal_wide_num_put_field_tests --parallelctest --test-dir build --output-on-failure -R '^(guest_libc_internal_wide_num_put_field|public_headers)$'(2/2 passed)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 repositoryImported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T10:17:42Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
13c6e21e15:tools/check_conventions.pyfailed.guest_libc_internal_wide_num_put_field_testsbuilt cleanly.guest_libc_internal_wide_num_put_field):Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T10:33:03Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: guard null
digitswhencountis positive before constructing the string.What I ran
Reviewed head
13c6e21e1571537dee7609ebd6ef996d403eb850. I read the prepared description, commits, manifest and diff, then inspected all changed source files and targeted locale, stream output and copy helper context throughrepo_read.py. No commands or tests were run.Results
Findings
Blocking
core/libs/prx/libSceLibcInternal/WideNumPutField.cpp:111:std::string raw(count, '\0')executes before the checked guest copy. Whencount > 0anddigits == nullptr, constructing the string passes a null source to the string constructor, causing undefined behavior beforeGuestCopyIn_nid_no_patchcan reject it. Validatedigitsbefore this construction, consistent with the neighboring narrow_Iputimplementation.Non-blocking
None.
Not verified
Build and test results were author-reported in the PR description and were not run in this review. The manifest lists six changed files; all six were read:
core/libs/prx/libSceLibcInternal/CMakeLists.txt,core/libs/prx/libSceLibcInternal/Err.cpp,core/libs/prx/libSceLibcInternal/WideNumPutField.cpp,core/libs/prx/libSceLibcInternal/include/ErrExports.hpp,core/libs/prx/libSceLibcInternal/tests/WideNumPutField.cpp, anddocs/dev/debt/changes/feat-libcinternal-wide-num-put-iput.md.files.jsonwas not available through the reader; the manifest showed every changed file included.To get this to a good state
Validate the digit pointer before constructing
raw, then rerun the reported build and targeted CTest commands on the updated head.Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T11:02:26Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
dccee43e62:tools/check_conventions.pypassed.guest_libc_internal_wide_num_put_field_testsbuilt cleanly.guest_libc_internal_wide_num_put_field):core/libs/prx/libSceLibcInternal/Err.cpp,core/libs/prx/libSceLibcInternal/include/ErrExports.hpp,core/libs/prx/libSceLibcInternal/WideNumPutField.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-21T11:09:16Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: initialize wide facet IDs and resolve facets using the repository’s locale rules before formatting.
What I ran
Reviewed head
dccee43e622a1dac3b87728846763c83f85c010f; no commands or tests were run. Read the prepared description, commits, manifest, diff, and all six changed files; compared the implementation with locale and output helpers inGuestLocale.hpp,LocaleSupport.cpp,NumGet.cpp,NumPutField.cpp, andTimeGetFields.cpp.Results
Findings
Blocking
core/libs/prx/libSceLibcInternal/WideNumPutField.cpp:35reads the widenumpunctfacet ID without initializing it. The ID is initialized to zero inLocaleSupport.cpp, andFindFacettreats zero as absent, soStreamWideNumpunctfalls back to constructing a standalone default facet. A custom locale's grouping and thousands separator are then ignored; additionally, if the fallback factory returns null, lines 120–121 dereference it. Initialize the ID and look up the stream facet with the same transparent-locale behavior used by the existing locale helpers.Not verified
Build and test claims in the PR description were not run during this review. The reviewed files are the six entries in the manifest:
CMakeLists.txt,Err.cpp,WideNumPutField.cpp,ErrExports.hpp,tests/WideNumPutField.cpp, and the debt change file. No files were excluded by the manifest.To get this to a good state
Initialize facet IDs consistently with the existing locale helpers and cover the uninitialized-ID case in the tests. Then rerun the reported convention check, build, and targeted CTest commands on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T11:57:39Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix grouping termination so
CHAR_MAXdoes not become a subsequent group size.What I ran
Reviewed head
77226e549e2a63378365e1d4316736ff2fced159using the pinned readerrepo_read.py. No commands or tests were run; the build and test results in the PR description are author-reported.Results
Findings
Blocking
core/libs/prx/libSceLibcInternal/WideNumPutField.cpp:84: When a grouping pattern ends with a positive group followed byCHAR_MAX(for example"\\2\\x7f"), this loop advances only while the next byte is positive. After consuming the first group it leaves the pointer onCHAR_MAX; the next iteration interprets that terminator as a signed negative value, which is not equal toCHAR_MAXwhenCHAR_MAXis 127, and casts it to a largesize_t. The loop then inserts a separator at an invalid position, causing incorrect output or invalid iterator use. Stop when the next grouping byte isCHAR_MAX; add a case with enough digits to cross the terminator. The existing test uses only five digits with a group of two, so it does not exercise another iteration after that terminator.Non-blocking
None.
Not verified
No tests, build, or convention checks were run. The PR description reports these checks as passing. All changed files listed in the manifest were read:
core/libs/prx/libSceLibcInternal/CMakeLists.txt,core/libs/prx/libSceLibcInternal/Err.cpp,core/libs/prx/libSceLibcInternal/WideNumPutField.cpp,core/libs/prx/libSceLibcInternal/include/ErrExports.hpp,core/libs/prx/libSceLibcInternal/tests/WideNumPutField.cpp, anddocs/dev/debt/changes/feat-libcinternal-wide-num-put-iput.md. No files were excluded in the manifest.To get this to a good state
Fix the grouping loop’s
CHAR_MAXhandling and add coverage for digits extending beyond the final specified group. Then rerun the reported build and tests.Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T12:14:47Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
77226e549e:tools/check_conventions.pypassed.guest_libc_internal_wide_num_put_field_testsbuilt cleanly.guest_libc_internal_wide_num_put_field):core/libs/prx/libSceLibcInternal/Err.cpp,core/libs/prx/libSceLibcInternal/include/ErrExports.hpp,core/libs/prx/libSceLibcInternal/WideNumPutField.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-21T12:38:55Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the review is complete and the inspected evidence supports merging.
What I ran
Reviewed head
a87e21b4701f3aa06da49f77a2235a4bcb018376. No commands or tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build, tests, and runtime behavior were not independently verified. All six changed files listed in the manifest were read:
CMakeLists.txt,Err.cpp,WideNumPutField.cpp,include/ErrExports.hpp,tests/WideNumPutField.cpp, anddocs/dev/debt/changes/feat-libcinternal-wide-num-put-iput.md. No files were excluded.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T15:27:59Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected implementation handles the reviewed formatting and grouping cases, but the reported build and test runs were not independently verified.
What I ran
Reviewed head
74e79cb9c3e4c39ea9c4ca66a01bb51b57fa7236using the prepared diff and pinnedrepo_read.pyreader. No build or test commands were run. Readcore/libs/prx/libSceLibcInternal/CMakeLists.txt,WideNumPutField.cpp,tests/WideNumPutField.cpp,include/ErrExports.hpp, andcore/libs/prx/libc/include/GuestLocale.hpp; the manifest lists all six changed files as included. The included full text was available through the pinned reader.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author reports convention checks, a targeted build, and two passing CTest checks; I did not run them. Runtime behavior beyond the inspected test cases was not verified.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T08:15:33Z.
Review: APPROVED
Reviewed — looks good
The implementation and its added tests cover the stated wide integer formatting behavior at head
86b60147528413a4b079a5c235c35ee2daf15754; no blocking defect was identified in the files reviewed.What I ran
No commands were run. I inspected the prepared diff and source files through
repo_read.py; the build and test commands listed in the PR description are author-reported, not independently verified.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The build, convention check, and CTest results were not independently run. No files were excluded by the manifest; all changed files were read:
core/libs/prx/libSceLibcInternal/CMakeLists.txt,core/libs/prx/libSceLibcInternal/Err.cpp,core/libs/prx/libSceLibcInternal/WideNumPutField.cpp,core/libs/prx/libSceLibcInternal/include/ErrExports.hpp,core/libs/prx/libSceLibcInternal/tests/WideNumPutField.cpp,core/libs/prx/libc/include/GuestLocale.hpp,core/libs/prx/libc/src/LocaleSupport.cpp, anddocs/dev/debt/changes/feat-libcinternal-wide-num-put-iput.md.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T18:06:52Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: propagate output iterator failure state from the wide output helpers.
What I ran
Reviewed head
e113c15386da0a868f3d95a6c4cded6b71c19e61. Read the prepared description, commits, diff, manifest, review README, and all changed source files through the pinned reader. No build or tests were run; the commands listed in the description are author-reported.Results
Findings
Blocking
core/libs/prx/libSceLibcInternal/WideNumPutField.cpp:141:PutWideFieldassigns the return ofLibcRepeatWideElement_nid_no_patch, but that helper callsPutWideElementon a local iterator copy and returns the unchanged copy. A failed stream-buffer overflow therefore sets only a temporary iterator'sfailedflag. The same applies to the wide element helper at lines 145 and 152._Iputcan return an iterator that still reports success after output failure, contrary to the test's stated behavior. Update the helpers to propagate the failure flag (or write through an interface that mutates the caller's iterator), and cover failure during both padding and digit output.Non-blocking
None.
Not verified
No build or tests were run in this review, and no behavior was checked on a physical console. The author reports a conventions check, target build, and two passing CTest cases. All eight changed files listed as reviewed in the manifest were read;
files.jsonwas not available through the reader, and no excluded files were identified in the manifest.To get this to a good state
Propagate the output failure state and add regression coverage for failure during padding and digit output. Re-run the target build and the two reported CTest cases on the updated head.