feat(libc): implement the std::__sce_v2 money_get virtuals #17539
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17539"
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 Danigamer05 on 2026-11-08T21:04:52Z.
What
Builds on #17331: this branch contains its commits, and through them #17296, #17277, #16975, #16949, #16944, #16924, #16919, #16560, #16516, #16214, #16178 and #15923, with current
main. It needs none of their code beyond themoneypunctvirtuals of #17277 and the stream helpers of #16919, which it calls, and their place inLocaleSupport.cpp, so it stacks to avoid conflicts. Until they merge, only the last commit is this PR's change.Implement the two virtuals of
std::__sce_v2::money_get<char>andmoney_get<wchar_t>, which_Makelocbuilds andstd::get_moneycalls. Before this PR, each of their four slots threwNotImplemented_nid_no_patch. These slots are not exports, so this PR adds no NID.The behavior comes from the
libc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6), vtables0x18C970and0x18D030. It was read from the disassembly ofdo_get(0xDA500,0xDA710,0xEA820,0xEAA50) and of the field reader (0xDA9D0,0xEAD10). The reader follows Dinkumware's_Getmfld, as its descendant in microsoft/STL (stl/inc/xlocmon) does, with this module's pattern encoding and call order:moneypunctfacet'sneg_formatfor every input. The pattern bytes are characters:$symbol,+sign,vvalue,xnone andspace; other bytes are skipped.showbasewhen the next character differs from its first, and optional in the last field when the sign has at most one character. Otherwise it must match, so a symbol before the last field is required once the input has ended.frac_digits, thengrouping, thenthousands_seponly when the grouping is not empty. A zero separator or a first group ofCHAR_MAXor more reads digits without separators. Otherwise each group's digit count saturates at 127 and is checked against the grouping. A zero decimal point matches nothing. Missing fraction digits are zeros, a short fraction fails, and a negativefrac_digitstakes no fraction.ctypeclasses as space (mask0x44), read from thechartable or throughwchar_t'sdo_is. A none field takes any number of them. Neither reads anything as the last field.do_getof along doubleconverts the digits with_Stodand keepserrno.do_getof a string widens them, resizing the destination as the module's string does: a heap string grows to at least half again its capacity.A new debt entry records that the
long doublecomes from this library's_Stod, and the_Makelocentry no longer listsmoney_get.Tested
Windows 11, MinGW GCC 15.2, Release, head on top of #17331. Not run on Linux or macOS, not run in a title.
guest_sce_v2_money_getcovers:CHAR_MAXgrouping;underflow, heap growth of the destination,errno, andwchar_twith non-ASCII separators._Makeloc.moneypunctfacets' fields: grouping withCHAR_MAXand negative bytes, symbols and signs of up to 7 characters, null and non-ASCII separators, fraction digits from -20 to 20, and shuffled patterns with stray bytes.errno; and the destination string, inline or on the heap.underflowanduflow, failing reads, and already-ended or held iterators.errno, thelong double's bytes and the destination string's size, capacity and text._Stodredirected to this library's: 900,000 calls over 3 seeds, 0 differences.long doublefor 120 or more digits (the new debt entry).guest_fopen_errorsskipped.CHAR_MAXgrouping, saturation, the rest of the sign, heap growth, null decimal points and separators, and the first-group check. The test was strengthened and catches all 16.check_conventions,git diff --check: clean. Merges cleanly withmain.pr_overlapreports no open PR with the same functions or conflicting code. It could not compare 50 PRs that conflict withmainon shared files. Of the 4 that touchLocaleSupport.cpp, #12518 exports the unversionedstd::money_get<char>vtable as zeroed data, a different symbol, and #9526, #11172 and #12704 do not touchmoney_get.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 gabichuuuuu on 2026-11-08T22:00:56Z.
Review: COMMENTED
Windows run of head
06da729920, merged ontomain0bae53facdin one tree with eight other open PRs that touch different files (all nine merged cleanly). Setup: Windows 11, WinLibs GCC 15.2 r7 (x86_64-ucrt-posix-seh, the CI toolchain), Release,BUILD_TESTING=ON.guest_sce_v2_char_facet_virtualswith--repeat until-fail:5: 5 / 5 pass.guest_sce_v2_codecvt_widewith--repeat until-fail:5: 5 / 5 pass.guest_sce_v2_collate_moneypunctwith--repeat until-fail:5: 5 / 5 pass.guest_sce_v2_facet_idswith--repeat until-fail:5: 5 / 5 pass.guest_sce_v2_messageswith--repeat until-fail:5: 5 / 5 pass.guest_sce_v2_money_getwith--repeat until-fail:5: 5 / 5 pass.guest_sce_v2_money_putwith--repeat until-fail:5: 5 / 5 pass.guest_sce_v2_num_get_charwith--repeat until-fail:5: 5 / 5 pass.guest_sce_v2_num_get_widewith--repeat until-fail:5: 5 / 5 pass.guest_sce_v2_num_put_charwith--repeat until-fail:5: 5 / 5 pass.guest_sce_v2_num_put_widewith--repeat until-fail:5: 5 / 5 pass.maindoesn't declare.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T11:52:51Z.
Review: DISMISSED
Reviewed — changes requested
The long-double overload narrows parsed monetary values to
double, losing precision beyond double before storing them aslong double.What I ran
Reviewed head
fb5ff0948f3d058a196f584468789b8715d83df8; no commands or tests were run. Readdescription.md,commits.md,manifest.json,diff.patch,LocaleSupport.cpp,GuestLocale.hpp, andGuestSceV2MoneyGet.cpp. All changed files were included in the review folder; no exclusions were reported.Results
Findings
Blocking
core/libs/prx/libc/src/LocaleSupport.cpp:3877—_Stod_nid_postfixreturnsdouble, sodo_get(long double&)loses precision before assigning the result to the long-double destination. This affects ordinary values that require more precision thandouble, not only the last bit after very long inputs. Parse through the library’s long-double conversion routine and preserve its error handling.Non-blocking
None.
Not verified
Builds, tests, runtime behavior on Windows, Linux, macOS, and console hardware were not verified in this review. The author reports a Windows 11 MinGW test run and differential testing in the PR description; these were not run here. Read all changed files listed by the manifest; none were excluded.
To get this to a good state
Use a long-double conversion for this overload, then rerun the money_get tests and relevant libc checks on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T17:24:29Z.
Review: COMMENTED
Reviewed — comments
The money field parser indexes an empty currency symbol when deciding whether a symbol is optional, which can cause undefined behavior for a valid facet with an empty symbol.
What I ran
1dd920efc4f173582901f03cd62b796170f25c97against the prepared diff; no commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libc/src/LocaleSupport.cpp:3738— The optional-symbol checks readsymbol[0]without first checking whether the currency symbol is empty. Amoneypunctfacet can provide an empty symbol, making this an out-of-bounds read. Guard the first-character comparisons whensymbol.empty()and add an empty-symbol test.Sources
The finding is based on the money field parser in the reviewed diff and its pinned-head source context.
Not verified
The full text of the changed files was included in the review bundle, but only the relevant parser and portions of the diff were read. The changed files reviewed were
core/libs/prx/libc/CMakeLists.txt,core/libs/prx/libc/include/GuestLocale.hpp,core/libs/prx/libc/src/LocaleSupport.cpp,core/libs/tests/GuestSceV2CharFacetVirtuals.cpp,core/libs/tests/GuestSceV2CodecvtWide.cpp,core/libs/tests/GuestSceV2CollateMoneypunct.cpp,core/libs/tests/GuestSceV2Messages.cpp,core/libs/tests/GuestSceV2MoneyGet.cpp,core/libs/tests/GuestSceV2MoneyPut.cpp,core/libs/tests/GuestSceV2NumGetChar.cpp,core/libs/tests/GuestSceV2NumGetWide.cpp,core/libs/tests/GuestSceV2NumPutChar.cpp,core/libs/tests/GuestSceV2NumPutWide.cpp, anddocs/dev/debt/libc.md; most were not read. No files were excluded by the manifest.To get this to a good state
Nothing is required. Optional: guard empty currency symbols and add coverage for that case.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T17:40:35Z.
Review: COMMENTED
Reviewed — comments
The money_get implementation is only partially reviewed; the other stacked changes have not been checked.
What I ran
e63ea76bc84a345512f9af48a6d111651184ad67; did not fetch the diff again.Results
Findings
Blocking
None verified in the code inspected.
Non-blocking
Not verified
core/libs/prx/libc/src/LocaleSupport.cpp(targeted range) andcore/libs/tests/GuestSceV2MoneyGet.cpp(full file). The prepareddescription.md,commits.md,manifest.json, anddiff.patchwere also read selectively.files.jsonwas unavailable through the review reader.To get this to a good state
Nothing is required. Please review the remaining changed files before relying on an approval decision.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:12:30Z.
Review: COMMENTED
Built the branch’s locale implementation and matching headers against the existing Linux runtime. The focused
GuestSceV2MoneyGetfixture passed.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.