fix(libs): parse decimals on macOS releases without floating from_chars #27767
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27767"
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 LODIBIDO on 2026-11-27T08:55:47Z.
What
On macOS releases before 26, libc++ has no floating-point
std::from_chars, solibSceNKWebKit/CharactersToNumber.cppandlibSceVideoOut/src/InputMapping.cppdo not compile (call to deleted function 'from_chars').Both now call
ParseDecimal_nid_no_patchin the newcore/libs/DecimalParsing.hpp.std::from_charsexactly as before.from_charsgeneral syntax (decimal numbers,inf,infinity,nan,nan(...)), converts withstrtod_lorstrtof_lin the C locale under the default floating-point environment, restores that environment anderrno, and reports overflow and underflow to zero asresult_out_of_rangewithout writing the value.The guard is the one in RavenCurseBurg's candidate fix for
UpscaleMode.hpp(744123f1bd, posted on #24341). This PR does not touch that file, solibSceAgcDriverstill needs that fix on these releases.#20016 also edits
InputMapping.cpp; thefrom_charscall it adds parses an integer.Refs #27647.
Tested
Native Intel Mac (i5-8259U, x86_64, no Rosetta, macOS 15.7.8, Apple clang 17.0.0), Release,
mainafdd33906bplus the diff of #27201 so that libc compiles.pad_input_mapping,guest_nkwebkit_numbers,nkwebkit_wtf,nkwebkit_wtftext,nkwebkit_wtftext_allocation,nkwebkit_doubletofixedandnkwebkit_doubletostringconverter: each passed 5 of 5.pad_input_mappinghas new cases for rejected syntax, range limits and a written zero.floatanddouble: no difference in error code, consumed length or result bits (for NaN: sign and NaN class, not the payload), by default, with a comma-decimal locale, withtr_TR.UTF-8andtr_TR.ISO8859-9, and with downward rounding and flush-to-zero/denormals-are-zero set.errno, the rounding mode and MXCSR were unchanged after each call.from_chars: the onlyfrom_charserrors left are inVulkanDevice.cppandPresentationPass.cpp, both fromUpscaleMode.hpp:25.libSceAgcDriver/tests/Recorder.cppneeds generated shader headers that were not built; with placeholder headers it reports nofrom_charserror. The pass also reports an unrelated error onmain,libSceAgcDriver/Execution/src/GuestMemory.cpp:4175(no matching function for call to 'min').tools/pr_overlap.pywas not run.Not tested: Linux, Windows, Apple silicon, macOS 26, any title.
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)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-27T09:03:37Z.
Review: COMMENTED
The fallback scans its special tokens in the caller's character locale before converting in the C locale.
strncasecmpuses the current locale on macOS, andstd::isalnumalso uses the current character locale. Floating-pointfrom_charsrequires C-locale syntax for the whole scan. Apple libc · C++ floating-point grammarI forced the exact fallback header at
ece6946fc027on Linux with a small adapter forLC_C_LOCALE, then compared with the ordinarystd::from_charsbranch. Withtr_TR.UTF-8,INF,INFINITY, and-InFiNiTy!returnedinvalid_argumentfor both float and double when the ordinary branch accepted them. Withtr_TR.ISO-8859-9, a NaN followed by a parenthesized non-ASCII letter also reported 6 bytes consumed where the C-locale parser consumed 3.A local variant using
strncasecmp_l(..., LC_C_LOCALE)andisalnum_l(..., LC_C_LOCALE)matched all 102 comparisons across C and both Turkish locales. Please make the character scan locale-independent as well. This checks the scanner contract. The two current callers reject or never generate these special tokens. The forced-branch test used Linux libc and did not run on macOS.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T09:13:17Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed change has no verified blocking defects; the reported macOS tests were not run in this review.
What I ran
Read the prepared diff and all four changed files at head
ece6946fc02790fa3cad337be239cacb96b44b15throughrepo_read.py. No build or test commands were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build and test results were not independently verified. Linux, Windows, Apple silicon, macOS 26, and console behavior were not tested in this review. All files listed as reviewed were read:
core/libs/DecimalParsing.hpp,core/libs/prx/libSceNKWebKit/CharactersToNumber.cpp,core/libs/prx/libSceVideoOut/src/InputMapping.cpp, andcore/libs/prx/libSceVideoOut/tests/InputMapping.cpp. No changed files were excluded.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T09:43:53Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: restore the saved floating-point environment even when conversion or classification fails.
What I ran
Reviewed head
c2aeb13ac63d603aacf2f5e7ef1cdb689a6b1884and its prepared diff. I read all four changed files listed in the manifest; no commands or tests were run.Results
Findings
Blocking
core/libs/DecimalParsing.hpp:68changes the calling thread’s floating-point environment toFE_DFL_ENV, then restores it only on the normal path at line 73. Ifstd::stringallocation at line 64 throws, or a conversion/classification operation fails exceptionally, the caller’s rounding mode and exception flags may remain altered. Guard the environment change with an RAII restore so every exit path reinstates it.Non-blocking
None.
Not verified
No tests or compilation were run. The PR description reports author-run macOS checks, but these were not independently verified. No files were excluded by the provided manifest; all four changed files were read.
To get this to a good state
Add exception-safe restoration of the floating-point environment, then rerun the relevant parsing and environment-preservation checks.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-27T09:54:40Z.
Review: COMMENTED
I retested the ASCII scanner on exact head
c2aeb13ac63d. The forced fallback matchedstd::from_charsin all 102 comparisons across C, Turkish UTF-8, and Turkish ISO-8859-9.For the floating-point environment follow-up, 72 checks passed across all four rounding modes. They cover successful, invalid, overflow, and underflow inputs, plus eight injected
std::bad_allocthrows from the temporary string allocation for float and double. The caller's rounding mode and pre-raised exception flags survived all cases. The allocation happens before the switch toFE_DFL_ENV, and the ordinary out-of-range return follows the restore. This experiment used the exact fallback on Linux with a C-locale API adapter. Native macOS remains the portability check.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:31:31Z.
Review: COMMENTED
pad_input_mappingandagc_driver_gcn_scalar_buffer_basepassed on main and the patched tree on the same Linux llvmpipe device with Vulkan required, shader cache disabled, and validation layer 1.4.369. Both logs show layer insertion and no missing-layer diagnostic orVUID-entry. A Linux fixture that selected the macOS fallback passed 20,052 conversion comparisons and caller-state checks. Native macOS remains outside this run.AI-assisted: yes.
Pull request closed