fix(libc): format strftime and asctime fields as measured on a PS5 #10129
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10129"
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 orezraey on 2026-10-23T10:35:12Z.
What
strftimeandasctimemeasured on a retail PS5 (firmware 13.60) with five homebrew probes callinglibSceLibcInternal.sprxfrom a payload process. The sources and console logs are in this gist (strftostrf4).strftimewas FreeBSD's; the console's is a different implementation. It now follows the console:%k,%l,%P,%s,%+,%v,%Qand any other unknown conversion%k)%k→13), or the letter alone (%Q→Q)%-d,%_d,%0e,%^a,%#b,%10Y)EorObefore a conversion%Ec=%c); before an unknown one dropped (%EE→%E,%Ek→%k)%EE→EESunorJan, also for%Aand%B;%m00?%m13, 14, …;%uand%wthe value mod 10?%d,%e,%H,%I,%M,%S,%j,%U,%W)%jat 1000):%Hof 101 is01%I(hour + 11) % 12 + 1, so hour -1 is11and -12 is00hour % 12or 12%Y,%G%y,%g99)%Ctm_year / 100 + 19mod 100 (year 1 →01, year 10001 →00)%U,%W(tm_wday + 7) % 7and(tm_wday + 6) % 7with the C remainder, so weekday 9 counts as 2 and -19 as -5tm_wdayas given%ztm_isdstis positive;tm_gmtoffignored, also printed fortm_isdst-1tm_gmtoff, nothing fortm_isdst-1%Ztzname[tm_isdst > 0];tm_zoneignoredtm_zone, elsetznameab%Ycdin 5 bytes writes onlyab) and the call returns 0; a composite is written part by part (%t%Din 8 bytes leaves\t10/02/)%cis%a %b %e %H:%M:%S %Y,%xand%Dare%m/%d/%y, and%ris%I:%M:%S %p, as before.asctimeuses the same field rules:"%s %s%3d %02d:%02d:%02d %04d\n"with those names, day, time and year (Fri Oct 56 00:61:61 2026for day 123456 and hour -10, year 10000 as0000). Before, the year was printed in full and an out-of-range name was???.Not followed:
%Eor%O; here that throws.%G,%gand%Vthrow for a negativetm_yday. The console gave%V01, 00, 00 and 52 fortm_yday-25, -13, -12 and -1 withtm_wday5, and 52 for -10 withtm_wday4; neither FreeBSD's ISO-week loop nor the variants I tried reproduce these, so the rule is unknown. They also throw for atm_ydaypast the end of the year and atm_wdaybelow -6:tm_yday400 of 2026 rolls into week 01 of 2027, but 415 of 1997 stays week 59 and 365 of 2013 week 53, andtm_wday-12 withtm_yday18 is week 04 where FreeBSD's loop gives 03 (JJenkx, ntamas94). Every ISO case inside the year withtm_wdayfrom -6 up matches, including the year boundaries. The ISO-week arithmetic is now 64-bit, so out-of-range fields no longer overflow.%Zprintstzname. The console'stznameand%Zwere both empty in the payload process; AnyPS5'stznamekeeps the host's names (separate debt entry).The debt entries record all of these, and that
fegetexceptflagwith a mask wider than 0x3f, which now also stores MXCSR control bits, was not measured.The
fetestexceptchange moved to #10175 and thememmem/memccpynote to #10176, as requested in review.Tested
main(f26434afa3, with #10706):6b1962e978. The test takes its declarations fromlibc/include/Api.hpp.guest_crt,guest_mktime,guest_strftime,guest_time_conversion,guest_time_extrasandguest_wide_formattingpass three runs in a row on Windows (MinGW) and on Linux (WSL Ubuntu, GCC);public_headersaudit andcheck_conventionspass.Windows 11, MinGW (winlibs), at head
c1ce36f9ee: this branch with currentmain(938812df14) merged in and #10134's commit2151929559kept.guest_strftimeis rewritten from the console logs: the conversions, the alternative forms, weekday and month -3 to 14, fields from -25 to 123456, years from -12345 to 12345, 14 ISO-week cases, the buffer limits andasctime. Onmainit reports 47 mismatches.guest_time_conversionnow checks the console's handling of the unknown and modified conversions, in place of FreeBSD's.974e0a89f2,guest_strftimealso checks%Uand%Won the ten out-of-range rows JJenkx and ntamas94 posted and the two composite rows that do not fit (%t%Din 8 bytes,%X%#Hin 2); with theTime.cppbefore that commit it reports 5 failures. The unknown ISO cases are not pinned in tests (removed in68a4482acdat oneandonlydean's request); they still throw inTime.cppwith their debt entry.guest_strftime,guest_time_conversion,guest_wide_formatting,guest_crt,guest_mktimeandguest_time_extraspass three runs in a row.git diff --checkis clean.tools/check_conventions.pypasses.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)libc.mdsection; this branch carries its commit until it merges); #6713, #8937, #10113, #10226, #10345 edit the same lines too (merge order only); #9613 edits the same lines too (merge order only); #10706 removes the test declarations this PR adds toGuestStrftime.cpp(merge order only); #10742 adds an entry next to the same debt line (merge order only)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T10:51:10Z.
Review: CHANGES_REQUESTED
The linked probe reports substantive strftime/asctime differences and the test matrix is broad. GCC 12.2 syntax checks passed for the changed source and tests; exact-worktree conventions, diff-check, and main-sync also pass (6 ahead/29 behind; merge clean). The author reports seven related Windows CTests passing three times; I did not run the full CTest suite locally. Please split the independent
fetestexceptimplementation/test/debt change into a separate topic PR from thestrftime/asctimeimplementation, as required by the repository’s one-branch-per-topic rule. The non-exportedmemmem/memccpynote is also separate from this formatter behavior and should move to a focused documentation change if retained. In addition, coordinate the debt-file integration with #10134: the pairwise heads conflict in the guest-time-conversion /__isfinitelsection. Refresh the formatter branch, rerun its focused tests and overlap/convention checks, and retain the measured probe caveats.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T13:23:30Z.
Review: CHANGES_REQUESTED
Re-review of current head
ed75f2fee18f75f03c79dfb2c68b5824b06ea049. The unrelatedfetestexceptandmemmemwork has been split out, and this PR now declaresDepends on: #10134; the remaining changed files are the formatter, its tests and the debt note. Exact-head conventions andgit diff --checkpass, and the author reports the focused formatter tests passing three consecutive runs after the refresh.The PR is currently
CONFLICTING/DIRTYagainst currentmain, so the current merged tree cannot be built or reviewed as a landing candidate. Please rebase onto currentmain, preserve the #10134 prerequisite and both sets of debt evidence, rerun the focused formatter/time tests, and update the report to the resulting exact head. This is the remaining integration blocker; no closure is requested.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T13:56:24Z.
Review: APPROVED
Re-review of exact current head
c1ce36f9eea92e4333e945172593911573299754.The prior blockers are resolved:
fetestexceptand the unrelatedmemmem/memccpynote are split into separate PRs; the branch now declares its #10134 dependency; and it is clean against currentmain(938812df14). The remaining diff is limited tostrftime/asctime, focused tests, and the corresponding libc debt note. The measured PS5 behavior and the explicitly unmeasured cases are documented in the PR.I independently ran
tools/check_conventions.pyon this exact head,git diff --check, and GCC C++20-Wall -Wextra -Werror -fsyntax-onlyon the changedTime.cpp; all passed. The author reports six focused Windows CTests passing three consecutive times. Current hosted eligibility, conventions, labels, report, relinker (Ubuntu/Windows/macOS including x86_64), ASan relinker, register-context, and write-watch checks pass. Linux and Windows full product build jobs were skipped by path policy; I did not run the six CTests locally.The #10134 dependency is explicit and its commit is present in this branch as described. Approving this exact head.