Repository navigation
fix(json2): accept a number that underflows to zero on libc++ - #12261
Merged
oneandonlydean merged 1 commit intoOct 28, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Open
MarcZX10
approved these changes
Oct 28, 2026
MarcZX10
left a comment
Contributor
There was a problem hiding this comment.
The change is narrowly limited to the libc++ fallback: it accepts a failed stream conversion only when the parsed value is zero, covering underflow while retaining the non-finite overflow rejection. The regression reproduces on macOS and passes repeatedly with the change; Windows CI also passes. The commit-charge/root checks and conventions pass. No blocking issue found.
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
libSceJson2's number parser falls back to an
istringstreamwhenstd::from_charsreportsresult_out_of_range, and it accepts the value only if the stream didn't fail (Export.cpp). With libstdc++, the stream sets failbit only on overflow, so a number that underflows to zero, such as2.4703282292062327e-324, is read as 0 and accepted. libc++ sets failbit on any ERANGE but still stores the value (±0, or ±inf on overflow). So on macOS the parse throwsnumber 2.4703282292062327e-324 overflows a double, andguest_json_numeric_localeaborts. A failed read whose value is 0 is now accepted. On libstdc++ nothing changes: underflow sets no failbit there, and overflow gives ±DBL_MAX. On libc++, overflow still gives inf and still throws, and1e309still throws as the test requires.The text reaching this line has already passed the parser's number grammar, so a 0 here can only come from underflow. #10378 replaces this block with its own decimal parser; the two would conflict, but this is a one-line fix. Announced on #1.
Tested
macOS 27.0.1 (26A434), Apple M4, Apple clang 21.0.0 (libc++), x86-64 Release build under Rosetta 2. The libraries don't link on macOS from
mainalone, so the tree ismain9fc181dde5plus the open PRs @imellag listed on #1 (#7631, #7804, #10552, #11249, #11447, #10669, #11554) and #12076.Export.cppand the test are the same there as onmain.ctest -R '^guest_json_numeric_locale$' -V:sce::Json::Parser::parse: number 2.4703282292062327e-324 overflows a double; the console's behaviour is unverified.--repeat until-fail:5).ctest -j4 --timeout 120with Vulkan: 2584 tests. Without the change, 61 failed. With it, 59 failed, with no new failures.guest_json_numeric_localenow passes, andprecise_wait, a known flake here, passed in that run.main: the 482 selected tests passed,guest_json_numeric_localeamong them.python3 tools/check_conventions.py --base upstream/main: passed.tools/pr_overlap.py: feat(libSceJson2): implement allocator-backed values and recovery #10378 (Export.cppL460-471).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