fix(libc): read swscanf floating fields as titles' libc.prx does #12514
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12514"
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-28T16:45:18Z.
What
The wide scanner's floating conversions (
swscanf, and the wide stream scanners that share it) differ from titles' ownlibc.prxin three ways. PPSA07923 and PPSA05916 agree on every row.1.
ERANGE. The titles set it only when a decimal field overflows or underflows to zero as along double, whatever the destination width. A hexadecimal field never sets it, and neither does a subnormallong double. #9973 (mine) restorederrnofor everyfloatanddoubleconversion, which is right below thelong doublelimits but not beyond them:%f/%lf%Lf1e39,1e400,1e4932errnounchanged1.2e4932,1e5000,-1e5000ERANGEERANGE%f/%lflefterrnoalone1e-4952,1e-5000ERANGEERANGE1e-4940,3e-4951(subnormallong double)%Lfset the host'sERANGE0x1p16384,0x1p-16446,0x1p99999%LfsetERANGE2. NaN. Every NaN,
-nanand-NaN(123)included, is stored as the default quiet NaN (0x7fc00000,0x7ff8000000000000, and the defaultlong doubleNaN). The scanner kept the sign and the payload.3.
%Lfwidth. The titles write the 10 bytes of the value and leave the other 6 of the 16 untouched. The scanner wrote all 16, and forinf/nanthe padding wasn't even zero.Floatnow converts the field withstrtoldonce to decideERANGE(decimal fields only, and only for a result of±infor0). It replaces a NaN result with the default quiet NaN and copies 10 bytes for%Lf. Values are otherwise unchanged. The debt entry now states the narrow-sscanfgap that remains on Windows:%fand hexadecimal%aset the host'sERANGE. #9973's old wording (%e,%lf) didn't match Windows.Tested
Current-main integration — 2026-11-04. Head
1da5a8eca8be1c0029a99e49398c2db26f6558c4includes mainb11c7bf84f5d2f636ff60166cc3371bd071e24d5and preserves previous public commits and attribution/licence notices. Keeps the measured floating-field/errno/10-byte long-double-store behavior alongside main’s now-merged #9863 short-field implementation and fixtures. The previously unanswered #9863 author question remains historical; its actual merge fulfills that prerequisite without asserting author agreement. The existing agreed #9087-first order remains.Linux x86-64, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON: rebuilt actual libc/Ampr and selected executables.
guest_wide_conversion,guest_wide_stream_scan,guest_stdio_variadic,guest_formatting,guest_scan_counteach pass 3/3 (15 runtime passes, zero skips);public_headers, conventions and whitespace checks pass. Pinned main passes all 17 selected baseline groups 3/3 (51 passes) plus headers. Before/after dependency checks agree: 34 recursive trees and 31,551 tracked blobs, zero errors; the update=none QuickJS test262 corpus is explicitly excluded from these library inputs.Source/parent/gitlink proofs, library/test hashes, raw logs/JUnit and head-leased push receipts: qualification archive, SHA-256
7c347f620951ad6f39068740750949212c6412815da094a46a96eca1d15c8bbf(download verified). Older platform, stress, negative-control and reference reports retain their original pins; no new Windows/macOS, full-suite, SDK-module, console, title/GPU or performance claim. AI-assisted: yes (Codex).Earlier dated qualifications below retain their original source/platform pins.
Latest Linux qualification (2026-11-02): exact head
949740512f65dc7439b0bacb25cccf2518c4fd25on pinned maina4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8. Production and tests equal the automatic current-main integration. Debt retains main’s corrected _WStoul behavior and the PR’s measured floating-range/errno/NaN and 10-byte long-double store qualifications.5 focused groups repeated three times: 15 passes, zero skips. Public headers, conventions, whitespace, raw libc/test builds and the actual production NID-patching command passed. MinGW syntax passed for ScanningWide.cpp. No new Windows/macOS runtime, bundled-SDK reference, native title, GPU or performance claim; earlier evidence retains its historical pins.
Earlier pinned qualifications follow.
Earlier Linux integration at
ccdd878bd9184e5031ddf1108c9d7044821ebeb9: merged mainbc3e33f4e334996ab9ba5cbf8544942465be18f3and rebuilt the actual libc plusguest_wide_conversion,guest_wide_stream_scan,guest_stdio_variadic,guest_formatting,guest_scan_count. Each suite passes three consecutive executions (15 passes, zero skips). Conventions and diff checks pass. #11341 is now merged and no longer a pending prerequisite; the #9863 author-order question was unanswered at that qualification; its later merge fulfilled the proposed order without an author agreement being claimed. Published by a normal fast-forward, retaining the previous public head as an ancestor. The latest-mainba5b5330b3merge preview is also clean; the executed build remains pinned tobc3e33f4e3. Earlier Windows/title-reference measurements below retain their original pins; this is not a new Windows or SDK-oracle run.Raw integrated-source proof, test/JUnit logs and commands, SHA-256
9ce7f31df10b0764765447028e834a947dadf6c060b90e5db4447b39afcb3203(download verified). AI-assisted: yes (Codex).Earlier qualification at the original pins:
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON, onmain6793a72475.Against titles' own
libc.prx: I loaded PPSA07923's and PPSA05916'slibc.prxnatively and called theirswscanf(HNnWdT43ues) side by side with this build. I compared the result, all 16 bytes of the destination,%nanderrno:maind i u o x X f e g a, every length, random widths and inputs)×3widths)-0casesThe same on both titles.
Tests:
guest_wide_conversion(new checks for the boundaries, hexadecimal, subnormal, NaN and the 10-byte store),guest_wide_stream_scanandguest_stdio_variadicpass in each of 3 runs. #9973's existing rows (1e39,1e400,1e-400,1e-50,1e-5000) are unchanged.Negative control: with
main'sScanningWide.cpp,guest_wide_conversionfails.Not tested on Linux or macOS. On Linux, glibc's
strtoldsetsERANGEfor subnormal results, which the zero/infinity test filters out as it does here.Overlap:
tools/pr_overlap.pyreports:%Lfstore line toGuestLongDoubleStore(target, strtold(...))for its Emscripten build. The current integration retains that helper through an aligned temporary followed by a 10-byte copy;docs/dev/debt/libc.md. The earlier overlaps with #12060 and #12420 are fulfilled history; both have merged.Merge order
The remaining open prerequisite is #9087, whose author agreed it lands first. #9863 has now merged and its short-field implementation and fixtures are retained in this integration; its earlier author-order question was unanswered, and no agreement is invented. #11341, #12060, #12420 and #10729 are also merged. The aligned long-double temporary and copy of only its 10 value bytes remain. Original requests remain historical: #11341, #9087, #9863, #10729, and #12060. Earlier agreements with #10729 and #12060 are fulfilled history.
Earlier qualification — 2026-10-30
Integrated upstream main
08a10d225306ad102b57408e2ef7566bcfb829b2atcb8b5a67e7613d42e6b2b666974960bb587e938d, 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: 9 passes (guest_wide_conversion, guest_scan_count, guest_stdio_variadic); public_headers 1 passes; no skips. MinGW source syntax and conventions pass.
No new Windows/macOS runtime, native SDK, game, GPU or performance claim. The Windows user pause was in force for that earlier qualification; the resumed native Windows results below supersede that limitation.
Evidence: immutable source and qualification receipts, SHA-256
61f5500e7526ea4e107159927de78c37db7e0ac1cb7ebd8625b22ab0ad5d9bd7(download verified).Qualification update — 2026-10-30, repeat 2
New current-main integration at
ece2c7c6b9ebe8c52c4d1e863f715e52ca7048e0on main51c31ea17e9f66cb36fe9655ec31c81610bfcfc9preserves previous qualified public 9140 head as a parent. The new main GuestLongDoubleStore writes 16 bytes; scanning now calls it into alignas(long double) 16-byte local storage and copies only 10 bytes into the caller. Single parse, errno/range rules, defaultNaN normalization and caller tail bytes remain. All other source, tests and public declarations equal the automatic merge.Three focused Linux groups passed 3 positive + 3 restored repeats (18 passes), public_headers passed, zero skips. Direct-to-caller helper mutant fails existing "swscanf stores ten bytes for %Lf" tail guard. Restored libc SHA256 matches positive binary. MinGW syntax passes; GNU -mlong-double-128 syntax passes only. No ARM/113-bit-host runtime, eight-byte ABI, console/nativeSDK/game/GPU claim. Windows worker owns separate 9-run exact-head qualification;9140 evidence stays historical.
Evidence: immutable qualification receipts, SHA-256
d8c837dd732aca9b0f5fa8dac5861da2b65e13c51e2506bb09264a671371f394(download verified).Earlier six-branch integration evidence at the original
9140c5cpin remains historical: https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/cpu-six-maine471-linux-20261030-repeat2.tar.gz (SHA-2560e170ba60a93a8b65f4dac8050f68833249b80b5ef519f05d38340700cedeb5b).Actual Windows follow-up at exact latest public
ece2c7c6b9ebe8c52c4d1e863f715e52ca7048e0, integrating main51c31ea: Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2 UCRT r7, Ninja Release, BUILD_TESTING=ON. Rebuilt patched libc and the three focused test executables. guest_wide_conversion, guest_scan_count and guest_stdio_variadic each pass three times: 9/9, 0 skips. The current wide conversion group includes the existing guard that %Lf writes only ten caller bytes.This directly tests the new composition with main's 16-byte GuestLongDoubleStore helper: the branch uses an aligned local and copies ten bytes into the caller. The prior Windows result at
9140c5cremains historical. The Linux direct-to-caller mutant evidence remains Linux evidence and is not claimed as a Windows rerun. Complete Windows FIFO request a35fc9f01ade4839ab4c63241df66ddc; no source/test mutation, SDK/game/GPU/performance/console or macOS claim.Evidence: https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/pr12514-main51c-windows-20261030.tar.gz, SHA256 1b575ea145355e74502723edbc591e5cce19575d599e97a8927e751c6245d482. AI-assisted: yes (Codex).
AI-assisted: yes (Codex).
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 MarcZX10 on 2026-10-28T16:55:04Z.
Review: CHANGES_REQUESTED
The floating conversion change and its focused cases look plausible, but the required overlap coordination is still missing. I compared the current PR head with the open heads of #11341, #9087, #9863, #10729, #12060 and #12420 using
git merge-tree. The combined trees conflict incore/libs/prx/libc/src/ScanningWide.cppfor #11341 and indocs/dev/debt/libc.mdfor each of the six PRs. The PR body currently saysDepends on: none; CONTRIBUTING.md requires the authors to agree which overlapping PR lands first and declare the dependency. Please coordinate that order with the affected authors and update the checklist (including any rebasing needed). I will reassess after the overlap is resolved. Current hosted Windows, Ubuntu relinker, Ubuntu register-context, ASan, conventions and policy checks pass; macOS relinker/register-context/write-watch checks are still pending, and Linux is skipped.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:24:22Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The Linux
guest_wide_conversionrerun and the Windows comparison with #12420 add useful evidence for the floating-scan behavior. I checked the exact head046d6598004971d26dedb689b3a4af7baa92a4c6against currentmainf99d7fece316e31878f0195f8bbc2ad2fbe635e4.What I checked
git merge-tree --write-treeproduces a clean current-main merge preview (2b966b4fabad2859ae68c9a03817526ad5af4d06).git diff --checkpasses.python3 tools/check_conventions.py --base refs/review/live-main --head refs/review/upstream-12514passes.319621ba2eand6793a72475respectively), not this current-main merge preview. I did not run the scanner tests locally.Still blocking
guest_wide_conversion,guest_wide_stream_scan, andguest_stdio_variadic) on the current-main merge result, or rebase/merge currentmainand report the exact tested head. A clean merge preview alone does not validate the integrated behavior.%Lfstore inScanningWide.cpp; #9863 overlaps the libc debt entry. Please record both agreements before treating the full overlap order as settled.The reported title-binary comparison is valuable, but it does not replace these current-integration and contribution-coordination checks. I will reassess after they are addressed.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T11:12:33Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The update supplies the requested Linux results on the
bc3e33f4e3integration (five focused suites, three repetitions each) and reports a clean merge preview against currentmainba5b5330b3. Since the files changed by this PR have no intervening current-main edits, I accept that as relevant test evidence under the merge-preview approach we discussed.The blocking overlap-order item remains: the author-order questions for #11341 and #9863 are still unanswered, and the update explicitly says no agreement is claimed. Please get both authors' agreement and record the same order in the applicable
Depends onchecklists. I am keeping changes requested until that coordination is explicit.