fix(libc): preserve partial wcsftime output on overflow #10895
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10895"
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 StoneDC on 2026-10-25T08:09:19Z.
What
Align wide time-formatting overflow with the reported native-PC run of firmware 13.42
libSceLibcInternal.sprx, following the requested review changes.A conversion writes as many 16-bit units as fit, but advances the logical position only when the complete conversion fits. Otherwise later format pieces reuse that position, and final termination may return a shorter nonzero prefix while retaining partial units beyond the terminator. A literal that does not fit still stops and returns zero. Expand compound conversions as complete pieces; retain the separate narrow
strftimestop-on-overflow behavior.Add 22 explicit boundary vectors derived from the reported rule and examples, including
%Y-%m-%dat each boundary, partial compound conversions, later literals, modifiers, unknown conversions, surrogate units, zero capacity, empty format, errno and untouched guards. Retain complete-output/reference cases and capacity safety checks, replacing the superseded flat-prefix overflow expectation. Set and restore the guest TZ explicitly so the existing%Zcomparison does not depend on the host's localized default zone name.Update the existing libc debt entry. The reference report is a firmware-module execution on a PC, not a physical-console measurement. I have not independently run its private loader, reproduced its 895-case reference campaign or verified
%Z/%z, conversion failures, null-argument differences or the large-count restriction. The last two remain unchanged gaps. The agreed test-integration order remains #10895 before #10987.Maintainer confirmation on 2026-11-01: firmware libSceLibcInternal.sprx is the intended target, and the reviewed head matches the reported 13.42 model. This closes the earlier target question. Source head remains
3d9db7dad635e0290f9e0a2808c593048ecb964d; no additional code or independent console/firmware run is claimed by this documentation update.Tested
Exact tested head:
3d9db7dad635e0290f9e0a2808c593048ecb964d; observed main snapshot:ba5b5330b37724bca4b99f30faab504653635a04. Upstream may advance after that recorded snapshot.Windows 11 / MinGW GCC 15.2 / CMake 4.3.1 and WSL Ubuntu 26.04 / GCC 15.2 / CMake 4.2.3, Release. Configure the actual full project with the existing dependency cache and supported FFMPEG_PREBUILT_DIR option, then build its real shared libc and the repository's
guest_wide_formatting_tests,guest_strftime_tests,guest_time_conversion_testsandguest_time_extras_teststargets. No repository build-file bypass is introduced.^guest_(wide_formatting|strftime|time_conversion|time_extras)$: 4/4 passed on each OS, no skips. The first Windows run exposed the existing default-zone-name assumption; the final exact tests set and restore guest TZ and pass on that same localized host.wcsftime firmware piece units, rather than an import or link failure. The new explicit cases execute on both real shared-library builds.patched_libraries, the remaining libraries/tests, macOS, PS5 hardware, game execution and a new firmware-loader campaign were not run.Current-main conventions with this complete description and whitespace checks pass. Python 3.9 grammar checks pass for changed Python files. Recorded main and the original published PR head are ancestors of this tested branch. Hosted follow-up verified on 2026-10-29 for this same final head
3d9db7dad635e0290f9e0a2808c593048ecb964d: Build run 40867077680 completed with every executed job successful, including full Windows, Linux/Windows/macOS arm64/macOS x86_64 relinker jobs and Linux ASan. The full Linux job was skipped and is not counted as passed. Conventions and the remaining reported checks also pass.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-25T08:18:06Z.
Review: APPROVED
The direct wide-character formatter preserves literal UTF-16 units, the established conversion behavior, and the tested partial-write boundary semantics. I reviewed the changed path and test cases; the author reports a focused ASan/UBSan harness, and the repository policy checks pass. Product build jobs are skipped by repository policy, so this approval does not claim an independent full integration build.
Imported from boykopovar/AnyPS5. Originally posted by thepoppfish on 2026-10-25T08:38:07Z.
Review: APPROVED
Independent native Windows validation of exact head
920903db939cef0943f4f381f1cc0a9df3e3f055. No blocking finding in the formatter change. Confirmed that its production/test blobs are unchanged from0ce70b465; the latest commit only trims the debt entry.Windows 11 build 26200, MSYS2 UCRT64 GCC 16.2.0-6 (SEH), CMake 4.3.1, Ninja 1.13.2:
Time.cpp,Environment.cpp,Multibyte.cpp,FormattingWide.cpp, and complete repositoryGuestWideFormatting.cpp/GuestStrftime.cpp. Both CTest cases pass, including three consecutive repeats of each. This exercises the UTF-16 literals/surrogates, capacity/guard checks, modifiers/composites, errno and oversized-count boundaries in the submitted tests, alongside the existing narrow formatter checks.wcsftimewith main's prior implementation, restoring its required<memory>/<new>includes. The wide test fails atwcsftime written prefix(0.06 s), whileguest_strftimestill passes.Process.cppdoes, a throwing unimplemented entry, and Windows abort-UI suppression. Two additional stream symbols are link-only placeholders:fgetwcaborts if called, and__stdoutpis null. The submitted tests do not exercise stream I/O. A GDB hardware read watchpoint on__stdoutp, set atmain, lets each complete test exit normally without a read; the aborting input placeholder is not called. Neither placeholder implements or changes time/conversion/memory-formatting logic. Full replay files are below.2742004ed28f765c7147db0e0269ff5868e9eb6fis clean.This adds focused native Windows evidence to the author's Linux results. It is not a full shared-libc/runtime integration build, stream-I/O test, sanitizer run, console measurement, game run or cross-PR composition test. No maintainer-triggered upstream native CI is claimed. AI-assisted testing and review: yes (OpenAI Codex).
Out-of-tree replay files
CMakeLists.txt:
Support.cpp:
IoPoison.cpp:
Use GCC 16.2 UCRT64 bin first on PATH, followed by CMake/Ninja. Configure with
cmake -S native-wide-time-review -B native-wide-time-review/build16 -G Ninja -DREPO=<exact-PR-checkout> -DCMAKE_CXX_COMPILER=<GCC16-bin>/g++.exe -DCMAKE_BUILD_TYPE=Release, build, then runctest --test-dir native-wide-time-review/build16 --output-on-failure. The negative control uses a separate build directory and-DTIME_SOURCE=<copy-with-only-old-wcsftime-and-required-includes>. For each executable,gdb --batch --nx -ex "set auto-load python-scripts off" -ex start -ex "rwatch __stdoutp_nid_postfix" -ex continue --args <exe>exits normally without a watchpoint hit after setup.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T09:58:36Z.
Review: APPROVED
Reviewed exact head
920903db939cef0943f4f381f1cc0a9df3e3f055.The wide formatter now writes each formatted piece directly into the caller buffer, retaining the prefix when capacity is exhausted and writing a terminator only for a complete result. The new tests cover capacities around each result length, zero capacity, empty output, multibyte UTF-16 units, surrogate code units, composite/modified/unknown conversions, errno, and the oversized-count boundary. The diff also exercises narrow
strftimethrough the shared formatter; the author’s target-level harness ran both wide and narrow formatting tests under ASan/UBSan, with repeated runs and a negative control using the baselinewcsftimeimplementation.The author updated the debt entry to retain only the remaining differences requested in review. I found no new overlap implementing partial wide output; #8855 is the merged predecessor. Hosted macOS and Ubuntu Debug/Release register-context, relinker, ASan, conventions, labels, and report checks pass; Windows product jobs are skipped by path policy. Local diff/convention checks pass. The PR explicitly discloses that the target-level harness is not a full product/shared-libc build and that native Windows/macOS, title, and console validation were not run; I did not independently run the harness.
No blocking issue found in the scoped partial-output change.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T06:23:38Z.
Review: APPROVED
Re-checked — approved
I clarified the reference question in my follow-up: for the console behavior scoped by #8855, firmware
libSceLibcInternal.sprxis authoritative; title-bundledlibc.prxresults are cross-checks and cannot establish firmware behavior when they differ. The current description now explicitly keeps the multi-piece/error boundary behavior unclaimed and unchanged pending a firmware measurement, and retains the remaining gaps in debt.The exact head
5be64730a23cb09a9ce5ed0136f4ec074a13f3a7preserves the previously reviewed formatter and tests while merging current main; the author reports the repository test suites plus ASan/UBSan harness passing, with a negative control. The documented full product/integration limitations are clear. Hosted relinker and policy checks pass; Linux and Windows product jobs are skipped by workflow policy. I did not rerun the harness locally.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T11:06:50Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The new firmware 13.42 measurement materially changes the evidence behind my earlier approval. The reported native comparison covers 895 cases twice and finds 368 differences on this head: 199 cases where the firmware returns the written prefix but this code returns 0, and 169 where it continues writing later format pieces after a conversion does not fit. The earlier review explicitly left those multi-piece/error boundaries unclaimed pending firmware evidence; that evidence is now available and contradicts the current behavior.
Please add focused regressions for the measured cases and align the implementation and debt description with the firmware results, or narrow the PR so it no longer claims the unverified multi-piece behavior. I am changing the review to request changes because the current tests do not cover the newly measured cases. The report is a firmware-module run on a PC, not a physical-console result, so please retain that limitation in the description.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T18:54:39Z.
Review: APPROVED
Re-checked — new head, looks good
The firmware-piece overflow finding is now covered by boundary cases, and all four focused formatting/time tests pass locally.
What I ran
3d9db7dad6against current mainbb04a4f1ea.Results
Unedited local test output
Unedited negative-control output
Unedited restored-test and conventions output
Negative control
Findings
Blocking
None found in the reviewed head.
Non-blocking
The follow-up comment 6502794473, created on October 29, says its hosted-check snapshot was checked on October 30. The current hosted checks are available and executed jobs pass; please correct or remove that future-dated snapshot line so the report timeline remains accurate.
Sources
Not verified