fix(libc): parse scaled NaN subjects without numeric conversion #12659
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12659"
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 JJenkx on 2026-10-29T00:46:49Z.
What
The six scaled floating conversion helpers now recognize NaN subjects before numeric conversion.
_Stodx("-nan", ...)previously returned a negative NaN and raisedFE_INVALID; a malformed payload such asnan(1.0)could also consume pastnan. Both bundled SDK references instead return the default positive quiet NaN, preserve floating flags, and consume a parenthesized payload only when all its characters are alphanumeric or underscore and it closes.This shares the existing
FindNanSubject/NanSequenceEndlexer through a host-only helper. The shared scaled parser uses its stop pointer and a typed quiet-NaN constant. Tests cover all six helpers, extreme 64-bit scales, rounding, sticky flags and null outputs.Tested
Head
f7b17598798ddae9f2b83c6a860ac6a332538f39, based on main3a2b91981651569163768854a1fcdc7193b6667b.guest_dinkumware_internals,guest_wide_conversion,guest_strtod_subnormal,guest_strings, each three times: 12 passes.libc.prxreferences, PPSA03766 and PPSA07923, agree on all 1,050 rows, covering all six helpers, 25 token spellings and seven scales includingINT64_MIN/MAX. The candidate matches every field: value bits, stop, errno, error output and floating flags. Main differs on 280/525 primary-helper rows.LD_DEBUG) and failsscaled NaN value bits. Its two AGC-only Bendy prerequisites do not alter libc._LLog(#11270),wcstod(#11892), ortimingsafe_bcmp(#12586), rather than this token correction; remaining uncomparable entries share debt text.Raw oracle rows, comparer, probes, patch, both-host logs and JUnit, SHA256
eef37c20aa6fac972d25bf48a024c72baf52c5a6104c986d7b0fc5a71e1981ef(download verified). No SDK/game binaries or disassembly are distributed. The references ran in Linux host processes, not on a console. Non-C locales, other SDK variants and unmasked exceptions remain unverified. Nonzero hexadecimal scaling remains documented and unimplemented. No title-unblock or speed claim.Current qualification — 2026-10-30
Integrated upstream main
08a10d225306ad102b57408e2ef7566bcfb829b2at58fddd82c67ac084cb2d8ca6a3aff862910e7daf, retaining the actual previous head and main as parents. Manual conflict resolution changes only debt documentation; production and test files equal the automatic merge output. Both parents' added test lines and main gitlinks are preserved.Linux CPU: 6 passes (guest_dinkumware_internals, guest_crt); public_headers 3 passes; no skips. MinGW source syntax and conventions pass.
Dependency #11270 has merged; its history and current-main LLog implementation remain, and the active Depends row may be cleared.
No new Windows/macOS runtime, native SDK, game, GPU or performance claim. The Windows user pause remains in force.
Evidence: immutable source and qualification receipts, SHA-256
61f5500e7526ea4e107159927de78c37db7e0ac1cb7ebd8625b22ab0ad5d9bd7(download verified).Independent Windows evidence from bunbeans2-arch: Windows 11 Pro, MSYS2 UCRT64 GCC 16.1.0, Release; head
58fddd82c67ac084cb2d8ca6a3aff862910e7dafintegrated with main98ddd9c179.guest_dinkumware_internals: change passed 5/5; reverting only production changes while retaining the regression tests failed 5/5 atscaled NaN value bits; plain main passed 3/3. This is the reporter's execution, not a new local Windows run.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 rooklz on 2026-10-29T01:26:29Z.
Review: COMMENTED
I checked this on macOS 26 (x86_64 under Rosetta, Apple clang, ASan+UBSan) at head
f7b1759879. I builtDinkumwareInternals.cppandStrings.cppby themselves with a small shim (__error→ hosterrno, an abortingNotImplemented_nid_no_patch, hostsin/cos/log*/tolower). I ranTestFloatErrorsand the newTestScaledNan. The fullmain()stops early at_Exp subnormal result classification, which comes from the shim's host math and doesn't involve this PR.DinkumwareInternals.cppwith the new test: RED atscaled NaN value bits, as the body says.3a2b919816;check_conventions --base upstream/mainpasses.Mutants. Killed: dropping the
*endstore, returning a negative quiet NaN, returning a signalling NaN, returningparse(text, nullptr), moving*error = 0below the NaN return (caught by the existing_Stodx in range),NanSubjectEndreturning the bare tail, dropping_from the payload set, accepting an unclosed payload, accepting any character up to), dropping digit0, and only accepting hex letters in the payload. Equivalent: restoringerrno = savedbefore the NaN return (it was never changed).Surviving, all in the shared
FindNanSubject/NanSequenceEndlexer that the scaled helpers now depend on:' '(no\t…\r),+sign not accepted,(*cursor | 0x20)dropped).No row in the case table has a non-space leading character, a
+sign, or an uppercase payload letter. One extra row kills all three, and head stays green with it:I got the expected stop for that row from the lexer's own rule, which
strtodalready uses. Could you confirm"\t+NAN(Az_0)"→ stop 11 against your twolibc.prxreferences before adding it?AI-assisted: yes