Skip to content

fix(libc): write a 36-byte struct tm as the console does - #10409

Open
ntamas94 wants to merge 11 commits into
boykopovar:mainfrom
ntamas94:fix/ps4-libc-tm-36-bytes
Open

ntamas94 wants to merge 11 commits into
boykopovar:mainfrom
ntamas94:fix/ps4-libc-tm-36-bytes

Conversation

@ntamas94

@ntamas94 ntamas94 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What

The console's struct tm is nine ints, 36 bytes, with no tm_gmtoff or tm_zone. AnyPS5's GuestTm was the 56-byte FreeBSD layout, so mktime, timegm, localtime_s, localtime_r, gmtime_s and gmtime_r wrote 20 bytes past a guest's struct tm, and strftime read the same 20 bytes back as an offset and a zone-name pointer. A guest with its struct tm on the stack has its canary overwritten and aborts on return. GuestTm is now 36 bytes:

guest_mktime gains a guard-byte test: each conversion gets a 64-byte 0xAA buffer and the bytes from 36 on must stay 0xAA. The tests that read the two removed fields now check the hour or the formatted text instead; guest_strftime gains a regression in its UTC+3 zone: a gmtime_s result (tm_isdst -1) formats %z|%Z as -0300|. guest_time_conversion's POSIX-zone check (Windows) derives the offset with timegm instead of tm_gmtoff.

The branch has current main merged in; Time.cpp is main's with this PR's struct and conversion changes on top, and the tests use the declarations of prx/libc/include/Api.hpp.

Tested

Windows 11, MinGW-w64 GCC (winlibs), Ninja, on this branch with main 828e443 merged in, three runs each: guest_mktime, guest_strftime, guest_time_conversion, guest_time_extras, guest_wide_formatting, guest_crt, guest_err and the four guest_ampr_* tests pass. Earlier, on 4168860: with main's GuestTime.hpp, Time.cpp and TimeExtras.cpp, guest_mktime aborts with "A calendar conversion wrote past the 36-byte struct tm". public_headers (audit) and python tools/check_conventions.py --base main pass. edubox's run of Fatal Frame II (PPSA32802) on Linux, above, shows the __stack_chk_fail after localtime_s gone with this change.

Measured on a PS4 Pro (firmware 10.71) with a homebrew probe: each call gets a 64-byte buffer filled with 0xAA (the first 36 bytes hold 2026-10-23 12:00:00 for mktime); touched is the offset just past the last byte that changed:

libc mktime touched=36
libc gmtime_s(returned buf) touched=36 (tm_isdst ffffffff)
libc localtime_s(returned buf) touched=36
LibcInternal mktime touched=36
LibcInternal gmtime_s(returned buf) touched=36 (tm_isdst ffffffff)
LibcInternal localtime_s(returned buf) touched=36

Bytes 36 to 63 stay 0xAA in all six calls, for the system libc.sprx and for libSceLibcInternal.sprx. The firmware 10.71 libSceLibcInternal.sprx agrees: mktime (offset 0xc230) reads offsets 0x0 to 0x20 of its argument, and the routine it and gmtime_s (0x1930) store through (0x1ff70) writes only offsets 0x0 to 0x20. Not run with a title.

A third probe (libc_tzname.c, 2026-11-08) calls localtime and strftime from the console's libc.sprx: 1736942400 gives tm_isdst 0, %Z empty (returns 0) and %z +0100; 1752580800 gives tm_isdst 1, %Z empty and %z +0200; sceKernelDlsym finds no tzname. The Windows checks #10987 added in guest_time_conversion now require the same: %Z empty, %z the zone's offset for that time (derived from the host zone the test runs in) and the zone's tm_isdst. With %Z printing tzname again, guest_time_conversion and guest_strftime fail.

A second probe on the same console (firmware 10.710.001) calls gmtime from libc.sprx: gmtime(1000000000) returns [40 46 1 9 8 101 0 251 0] and gmtime(951825600) [0 0 12 29 1 100 2 59 0], so tm_isdst is 0 there, and mktime of either result is one hour earlier than the timestamp (999996400, 951822000): the console's zone is one hour east of UTC in standard time, and both results are read as standard time, the September one included. guest_mktime now checks both values and that round trip in CET-1CEST; with gmtime storing -1 again it fails ("gmtime did not store tm_isdst 0").

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: fix(libc): format strftime and asctime fields as measured on a PS5 #10129
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

The console's struct tm is nine ints with no tm_gmtoff or tm_zone
(measured on a PS4 Pro, firmware 10.71: mktime, gmtime_s and
localtime_s change 36 bytes of a 64-byte buffer, in libc and in
libSceLibcInternal). GuestTm was the 56-byte FreeBSD layout, so the
conversions wrote 20 bytes past a guest's struct tm. gmtime_s stores
tm_isdst -1 as the console does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MarcZX10

Copy link
Copy Markdown
Contributor

I reviewed the patch and its test coverage. Two items need coordination before merge:

  1. fix(libc): format strftime and asctime fields as measured on a PS5 #10129 is still open and changes the same Time.cpp %z/%Z behavior. Its PS5 measurement explicitly ignores tm_gmtoff/tm_zone; this PR removes those fields and changes the same branches. Please agree a landing order with that author and record the required Depends on: #N (or document the agreed rebase plan if either order works).
  2. The 36-byte layout evidence reported here is from a PS4 Pro on firmware 10.71. Since this changes the guest ABI for PS5, can you add direct PS5 evidence or explain why the PS4 layout is known to match the PS5 ABI? fix(libc): format strftime and asctime fields as measured on a PS5 #10129’s PS5 strftime results support the timezone-source behavior but do not by themselves establish the size of struct tm.

I have not approved pending those points; the hosted checks I saw were still running for Windows relinker and macOS write-watch.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 14478 core/libs/prx/libSceNKWebKit/src/WtfTime.cpp L575

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 7447 docs/dev/debt/libc.md
PR 7544 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8965 docs/dev/debt/libc.md
PR 9087 docs/dev/debt/libc.md
PR 9340 docs/dev/debt/libc.md
PR 9371 docs/dev/debt/libc.md
PR 11172 docs/dev/debt/libc.md
PR 11332 docs/dev/debt/libc.md
PR 11661 docs/dev/debt/libc.md
PR 11689 docs/dev/debt/libc.md
PR 11698 docs/dev/debt/libc.md
PR 12849 docs/dev/debt/libc.md
PR 15973 docs/dev/debt/libc.md
PR 16791 docs/dev/debt/libc.md
PR 17557 docs/dev/debt/libc.md

@ntamas94

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Thank you for the review.

1. Order with #10129. I proposed on #10129 that it lands first (comment); this PR now lists Depends on: #10129. Once #10129 is in, I will merge main into this branch (no force-push), keep #10129's %z/%Z code as it is and drop my edits to those two branches, so this PR is left with the struct size, the conversion write-backs and gmtime_s's tm_isdst of -1. The macOS PRs #4627 and #8658 also copy tm_zone into the host struct tm in toHostTm; whichever of us lands second removes that line.

2. PS5 evidence. I have no PS5 and no PS5 title or PS5 system module on disk, so I cannot measure or read the PS5 struct tm size directly; the 36-byte figure is from a PS4. What I can add:

  • The two titles I measure with are PS4 titles that AnyPS5 runs today, and both import these functions through the code this PR changes: mktime, gmtime, localtime and time from both libc and libSceLibcInternal, gmtime_s from libSceLibcInternal, and strftime from libc (Gang Beasts CUSA04865, Knowledge is Power: Decades CUSA12435). A PS4 title allocates a 36-byte struct tm and AnyPS5 writes 56 bytes into it: that alone corrupts the caller's stack, whatever the PS5 layout is.
  • fix(libc): format strftime and asctime fields as measured on a PS5 #10129's own PS5 probe (strf2 in its gist) was compiled with a struct tm that has tm_gmtoff at offset 40 and tm_zone at 48. On the PS5, tm_gmtoff = 19800 and tm_gmtoff = -1 both printed %z as -0300, and tm_zone = "XYZ" and tm_zone = NULL both printed %Z as empty: the PS5 strftime reads neither offset. That is consistent with a 36-byte PS5 struct tm, but it does not prove the size, as you say: it says nothing about what the PS5 mktime or gmtime_s write.

So the PS5 size stays unmeasured. If you would rather not change the guest ABI on PS4 evidence alone, I can add a debt entry stating that the PS5 layout is assumed from the PS4. A PS5 owner could also run the 64-byte guard probe from the description, which takes one call each to mktime, gmtime_s and localtime_s.

@github-actions github-actions Bot added the libc label Oct 23, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking compatibility mismatch with the measured console behavior documented in dependency #10129. That PR records that %z is emitted even when tm_isdst == -1, and %Z selects tzname[tm_isdst > 0] (the standard-name slot when the value is -1). This PR makes gmtime_s set tm_isdst to -1, but formatTime currently breaks out of %z for every negative value, guestZoneName returns an empty string for %Z, and the updated unknown dst fixture expects [][]. Once GuestTm no longer carries zone fields, these paths need to preserve #10129’s measured rule using the guest timezone globals. Please add a regression for a non-UTC guest zone formatted from a gmtime result and align both conversions with the dependency’s recorded behavior before merging.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
… zone

gmtime_s now stores tm_isdst -1, so strftime must not drop %z or empty
%Z for it. Follow the rule boykopovar#10129 measured on a PS5: %z is the guest
zone's offset, one hour more only when tm_isdst is positive, and %Z is
tzname[tm_isdst > 0].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ntamas94

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Thanks, both points are fixed in 4168860. I first merged today's main (ca7bf03) into the branch, with no rebase and no force-push. The only conflict was the macOS tm_zone copy in toHostTm, which goes away with the field.

1. %z/%Z for tm_isdst -1 now follow #10129's rule, from the guest zone globals:

  • %z no longer stops at a negative tm_isdst. It prints the guest timezone offset, plus one hour only when tm_isdst is positive, so -1 prints the standard offset.
  • %Z is tzname_nid_postfix[tm_isdst > 0], the guest tzname, so -1 takes the standard-name slot. It no longer returns empty for -1 or reads the host's _tzname.
  • The unknown dst fixture now expects [+0530][IST].
  • guest_time_conversion's %+ checks on a gmtime_s result expect the zone name again (UTC, 28 bytes). Its tm_isdst 0 and 1 checks compare against the guest tzname rather than the host's.

2. Regression for a non-UTC zone from a gmtime result. guest_strftime sets TZ to IST-5:30, calls gmtime_s on 1699992800, requires tm_isdst == -1, and requires %z %Z to format as +0530 IST (9 bytes).

On the merge head with the fix, Windows 11, MinGW-w64 GCC (winlibs), Ninja, run three times:

  • guest_mktime, guest_strftime, guest_time_conversion, guest_time_extras, guest_wide_formatting, guest_crt, guest_err, the three guest_ampr_* tests and the other tests the filter selects: 14 of 14 pass each time.
  • With main's GuestTime.hpp, Time.cpp and TimeExtras.cpp on the same head, the guard-byte test still aborts: "A calendar conversion wrote past the 36-byte struct tm".
  • python tools/check_conventions.py --base origin/main passes.

The description is updated to match; it no longer says a UTC struct tm formats %Z as empty.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 23, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the updated head. The 36-byte GuestTm layout and the %z/%Z handling now match the console measurements and the behavior recorded in #10129, including tm_isdst == -1. The added guarded-write and non-UTC gmtime formatting regressions address my prior finding. No blocking issue remains in this diff.

@MarcZX10

Copy link
Copy Markdown
Contributor

I manually compared the exact current heads of #10409 and my #10987 after the overlap checker flagged shared time files. A three-way merge reports conflicts in Time.cpp and the GuestTimeConversion / GuestWideFormatting tests. More significantly, this PR removes GuestTm.tm_zone, which #10987 currently sets and tests. The UTF-8 conversion still matters for the guest tzname globals and %Z, but that follow-up will need to be adjusted to the 36-byte GuestTm layout. I suggest #10409 land first, then I can rebase and adapt #10987; does that order work for you? I have not changed your branch or declared a dependency before coordinating.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@ntamas94 Thanks. The PS5 side agrees with your PS4 probe: a PS5 title's bundled libc.prx writes exactly nine ints in gmtime_s/localtime_s and stores tm_isdst = -1 from gmtime_s, so the 36-byte layout is right.

Two things before this can go further:

  1. Please rebase onto current main. fix(libc): format strftime and asctime fields as measured on a PS5 #10129 has merged, so main already has the %z/%Z handling (addZoneOffset, tzname[tm_isdst > 0]) and its own timezone/tzname declarations. Please keep main's version of that code and drop this PR's copy, and keep your struct and conversion changes. The branch currently conflicts in Time.cpp and the five time test files.
  2. In the tests, please use the declarations from prx/libc/include/Api.hpp instead of the local extern "C" blocks. main's time tests already include that header, and each export should be declared only once, in the public header.

@edubox

edubox commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Tested with a real title: Fatal Frame II: Maiden of Black Water PPSA32802 (retail dump, 01.002.002), Linux, RTX 4080 SUPER, Vulkan 1.4.351.

I merged this branch onto current main locally (the head is based on ca7bf03) and supplied the two std::numpunct<wchar_t> symbols locally so the title's loader gets past its libc.prx imports.

  • Before: the title aborts 2–11 s in with __stack_chk_fail from a guest function that calls localtime_s. The guest reserves exactly 0x30 bytes for the tm (rbp-0x50, stack canary at rbp-0x20); the 56-byte GuestTm writes tm_zone at offset 0x30, straight over the canary.
  • With this change: no canary failure. The title runs and stops 13 s in at the existing blocker NGS2: custom submixer racks with 12 channels are not implemented, which is the expected next stop.

So this fixes the crash on a real title. For current main the only conflict is in Time.cpp (formatTime/twoDigitYear from main alongside the 36-byte conversions); the test conflict resolution is mechanical.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@edubox thanks, that's useful evidence: the 0x30-byte guest tm with the canary right after it is exactly the layout this PR fixes, and __stack_chk_fail going away with it on a real title is a strong signal. @ntamas94 the PR still needs the rebase from our earlier comment (keep main's %z/%Z code from #10129 and this PR's struct and conversion changes); after that we'll take it through review and CI.

@JJenkx

JJenkx commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@ntamas94, following up on the reviewer overlap finding for our #12549. Its normalization change is now qualified at 5d02c43cc567d638269e1ae818fd7030cc1a32a7: keep moved = 0 for an in-range nonordinary calendar, while rebuilding ordinary fields before the host mktime call. Both Linux and actual Windows pass the six focused time groups three times each. This preserves your separate 36-byte GuestTm ABI work.

I compared your 4168860c2d with current main 319621ba2e and with updated #12549. Both merge previews have the same four conflicting files and identical conflict blocks; #12549 introduces no additional conflict block. The raw previews and comparison are in the evidence archive.

Could you confirm the landing order? I propose #12549 first, then #10409 refreshed onto main, preserving the in-range normalization guard and equivalent-calendar test. If either order is acceptable once #10409 is refreshed, that also settles the review concern. I will record your actual answer rather than presume agreement.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thank you for your work on this. Main has moved, and the PR now conflicts in:

  • core/libs/prx/libc/src/Time.cpp
  • core/libs/tests/GuestMktime.cpp
  • core/libs/tests/GuestStrftime.cpp
  • core/libs/tests/GuestTimeConversion.cpp

Could you merge current main into your branch or rebase onto it, keeping the existing review fixes? The points from our earlier review are also still open.

Thank you!

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed docs labels Nov 9, 2026
ntamas94 and others added 2 commits November 12, 2026 11:45
# Conflicts:
#	core/libs/prx/libc/src/Time.cpp
#	core/libs/prx/libc/src/TimeExtras.cpp
#	core/libs/tests/GuestMktime.cpp
#	docs/dev/debt/libc.md
The check added in boykopovar#17417 compared timegm's output with gmtime_s's, which
stores tm_isdst -1 on this branch as the console does; timegm stores 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ntamas94

Copy link
Copy Markdown
Contributor Author

I merged current main (3b7f31fa70) into the branch as 71c96459d6. 42bda7d256 then adjusts one new test.

Conflicts:

  • Time.cpp (gmtime) and TimeExtras.cpp (gmtime_r): main added an early null check. It is kept, and so is this branch's tm_isdst = 0 after gmtime_s.
  • GuestMktime.cpp:
    • CheckFailure now takes main's daylight hint. The tm_gmtoff and tm_zone assignments are dropped, because the 36-byte GuestTm has neither field.
    • In main, both sides' check calls are kept.
  • docs/dev/debt/libc.md: this branch's tzname entry is kept, without tm_zone, and main's new mktime daylight-hints entry is added.

42bda7d256: the timegm check from #17417 compared timegm's output with gmtime_s's. On this branch gmtime_s stores tm_isdst -1 and timegm stores 0, as measured on PS4 Pro, firmware 10.71 (PS4 behaviour, not PS5). So the check now expects 0.

Tests on the merge head (Windows, WinLibs GCC, Release):

  • guest_time_conversion, guest_timespec_get, guest_mktime, guest_time_return, guest_time_extras and guest_strftime: 6/6 passed.
  • The public_headers set: 65/65 passed, with none Not Run.
  • tools/check_conventions.py --base main passed.

AI-assisted: yes

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 13, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — comments

The change addresses the reported struct tm over-write, but I did not read every reviewed file or run the reported checks, so a formal approval is not justified.

What I ran

Reviewed head 42bda7d256cf30779cee7cd93b8ab618d1441d35 using the pinned repo_read.py reader. No tests or builds were run.

Results

Check Result Note
Diff inspection passed Prepared diff reviewed
Tests and build not run Results in description are author reported

Findings

Blocking

None identified in the portions inspected.

Non-blocking

None.

Not verified

The report says Windows 11 MinGW-w64/Ninja tests and convention checks passed, and describes console probes; these were not run or independently verified. Read the description, commits, manifest, diff, GuestTime.hpp, portions of Time.cpp and TimeExtras.cpp. The remaining portions of Time.cpp, and the changed test and documentation files, were not read. All nine changed files are listed as reviewed in the manifest; their full texts were included, but not all were inspected. No files were excluded by the manifest.

To get this to a good state

Nothing is required. This is a review comment because the review was incomplete.

ntamas94 and others added 2 commits November 22, 2026 10:14
# Conflicts:
#	core/libs/prx/libc/include/GuestTime.hpp
#	core/libs/prx/libc/src/Time.cpp
#	core/libs/prx/libc/src/TimeExtras.cpp
#	core/libs/tests/GuestTimeConversion.cpp
#	core/libs/tests/GuestTimeExtras.cpp
#	docs/dev/debt/libc.md
The guest tm carries no tm_gmtoff, so setToCurrentLocalTime and
calculateLocalTimeOffset take the offset from the difference between
the local and UTC fields of the same time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ntamas94

Copy link
Copy Markdown
Contributor Author

Merged current main (c873d86ba9) and added 28df803867.

Conflicts: main had touched the lines around the 36-byte GuestTm in GuestTime.hpp, Time.cpp, TimeExtras.cpp, both time tests and docs/dev/debt/libc.md. Each side kept its intent: the 36-byte layout and no tm_gmtoff/tm_zone writes from this branch; LibcSetProcessTimeSource_nid_no_patch, the merged null checks, gmtime_r in the conversion test and the 400-year mktime sentence from main.

New commit: main's WtfTime.cpp (#24493) now reads tm_gmtoff from the guest localtime_r in setToCurrentLocalTime and calculateLocalTimeOffset. With the console's 36-byte tm that field does not exist, so both take the offset from the local fields minus the UTC fields of the same time (day shift from tm_yday/tm_year). GuestNKWebKitDates.cpp checks the minute offset the same way.

Tests on the merge head (Windows, WinLibs GCC 15.2, Release): guest_time_conversion, guest_timespec_get, guest_mktime, guest_time_return, guest_time_extras, guest_strftime and guest_nkwebkit_dates passed. Note: libSceNKWebKit.prx does not link on current main with MinGW (multiple definition of WebCore::Region::~Region() and Region(Region&&) between Region.cpp, RoundedRectRegion.cpp and WebCoreAffineTransform.cpp), independent of this branch; for the WebKit test I linked it locally with --allow-multiple-definition, not committed. tools/check_conventions.py --base origin/main passed.

AI-assisted: yes

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the implementation and tests support the stated 36-byte guest struct tm layout and the reported console formatting behavior.

What I ran

Reviewed head 28df803867fe7ddaae1a6839ba57985ff06eed3b against base main using the prepared diff and pinned repository reader. No test commands were run; the Windows and console runs described in the PR body are author-reported.

Results

Check Result Note
Changed-line review passed All 10 changed files inspected
Targeted code review passed Conversion and WebKit callers inspected
Tests run by reviewer not run No commands run
Author-reported checks not run Results not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

I read all changed files listed in the manifest and the relevant conversion, formatting, WebKit caller, and test code. I did not run tests or independently verify the console probes, Windows results, title behavior, or CI. The PR description and commit list were read; excluded files: none.

To get this to a good state

Nothing is required.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 22, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@ntamas94 this head (28df803) fails guest_libc_internal_facet_put when run alone on main 4fbe5c4. I have held it; the hold lifts when a new head passes it.

@malekaifa malekaifa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking transitive regression on exact head 28df803867fe7ddaae1a6839ba57985ff06eed3b.

The 36-byte GuestTm change itself is well supported, but the %Z change in libc also changes libSceLibcInternal C++ time_put<wchar_t> even though this PR only cites console evidence for libc/strftime behavior. libSceLibcInternal/FacetPut.cpp forwards its wide do_put to LibcWideTimePutDoPut_nid_no_patch, and that helper formats through wcsftime_nid_postfix. Therefore changing libc case 'Z' to emit nothing makes LibcInternal time_put<wchar_t>::do_put('%Z') emit nothing too.

That is exactly inconsistent with the existing non-Windows regression in GuestLibcInternalFacetPut.cpp: CheckWideTimePutDoPut() sets a 15-letter zone (ABCDEFGHIJKLMNO0) and requires %Z to produce ABCDEFGHIJKLMNO; it separately verifies the 16-letter case returns empty only because the first buffer cannot fit it. oneandonlydean has now reproduced guest_libc_internal_facet_put failing on this exact head and put the PR on hold until a new head passes it.

Please do not just delete/weaken that check without evidence. Either:

  • preserve the existing LibcInternal facet %Z behavior by decoupling its formatter from libc's newly measured %Z rule, while keeping the 36-byte struct and libc %Z fix; or
  • provide LibcInternal/time_put console evidence showing %Z is also empty there, then update the LibcInternal implementation/test deliberately to that measured behavior.

Note that libSceLibcInternal/Export.cpp has its own %Z path (GentimeField(Zone, ...)) that still emits a zone field, so the current PR otherwise leaves LibcInternal time formatting internally inconsistent.

Please rerun guest_libc_internal_facet_put on the new exact head in addition to the existing libc time tests. Hosted checks being green on this head do not cover this isolated failure.

AI-assisted: yes

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants