fix(libc): print %C, %S and a zero %lc in the printf families as titles' libc.prx does #12397
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12397"
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-28T12:25:39Z.
Current refresh: head
51f8ea279c7dd2391fd39e4265579bb45b604b01includes main151a2cb6e274; scoped Linux CPU tests12/12, main24/24, public headers and regression controls pass. Current evidence is in the refresh comment; earlier platform reports retain their original pins.What
Titles' own
libc.prx(PPSA07923 and PPSA05916 agree on every row) prints these narrowprintfconversions differently from here:%C0xe9%C(2 bytes), no argument takené(as%lc)%5C|/%-3C|0xe9%C|/%C |é|/é |%hC,%lC,%#C0xe9%C%hC,%lC)%C%d65%C65Aand the next argument%lc0%3lc|0|: the width is ignored%hS|,%lS|u"aé€"%SSo
%Cis one of the unknown conversions this library already prints as%and its letter, padded to the width, without taking an argument (#11907). The change:CleavesKnownConversions;ApplicableLengthdrops the length ofS;%lcof 0 writes nothing.%lsand%Sretain their previously measured handling. The%lcadapter now ignores precision before writing the whole UTF-8 sequence and keeps byte-based field width: for U+00E9,%.1lcwritesc3 a9, and%5lcwrites three spaces followed byc3 a9. A zero wide character still writes nothing, including width/precision combinations.swprintf(second commit): in the titles' wide formatter neither%Cnor%Sis a conversion, with or without a length.%C|%5C|%hC|%S|%-3S|%lS%dwith 7 prints%C| %C|%C|%S|%S |%S7. Here both formatted their argument as%lc/%ls; they now take #11907's unknown-conversion path.%lc,%ls,%hsand valid UTF-8%salready matched. A wide%cor%sof bytes from 0x80 up is handled by #9964 and #9953, not here.One existing check changed:
"%2$ls|%1$C|%3$d"expected%1$Cto printA. Positional%Cwasn't measured, so that check now uses%1$lc; its purpose (a positional wide argument) is unchanged.Tested
Current-main integration — 2026-11-04. Head
c9d920d13a54745eba08af179a5cba8a8421eb85includes mainb11c7bf84f5d2f636ff60166cc3371bd071e24d5and preserves previous public commits and attribution/licence notices. Retains the measured nonconsuming%C/literal%Sbehavior and main’s newer invalid multibyte character guard. The former #11907 prerequisite is now merged.Linux x86-64, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON: rebuilt actual libc/Ampr and selected executables.
guest_formatting,guest_wide_formatting,guest_stdio_variadic,guest_wide_conversioneach pass 3/3 (12 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
4816b33918cad6ec1bd9b963aecea143f27fac49on pinned maina4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8. Uses the actual updated #11907 parent. Preserves measured narrow/wide %C/%S and length behavior, main’s UTF-8 helper/error handling, all added main fixtures and both sets of child regressions.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 Formatting.cpp, FormattingWide.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.
Current-main Linux integration at
464a7f3e28988bf785c2ac267f883843699a8006: merged mainbc3e33f4e334996ab9ba5cbf8544942465be18f3and rebuilt the actual libc plusguest_formatting,guest_wide_formatting,guest_stdio_variadic,guest_scan_count. Each suite passes three consecutive executions (12 passes, zero skips). Conventions and diff checks pass. The libc debt conflict is resolved by retaining the updated printf description and main’s newasinhentry. 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
54e3d599fbfc9317fe9d88d713a7fa2516d887652579c710df445cc44aba098c(download verified). AI-assisted: yes (Codex).Earlier qualification at the original pins:
Exact follow-up head
41cfd4560a227a30c4848186ba6b8568998835e6:guest_formatting,guest_wide_formatting, andguest_safe_errorsrepeated three times: 9 executions per host.snprintf_sandsprintf_sreplays each match48 rows against both references. Windows replay coverssnprintf; its focused suite also checks shared safe-formatting behavior.%5lc/U+00E9 is five bytes: three spaces plus the two-byte character. The fix preserves this measured behavior while removing precision truncation.Probe sources, raw rows, both-host logs, JUnit, patch and negative controls, SHA-256
082d9f9ec17d5afc4ebe582699b77cebf45d5529d2b9a72b0813990e0aa34468(download verified). References ran on Linux, not a console; other locales/SDKs and native-title effects remain unverified. This qualifies the published PR branch, not a current-main integration; the separate rebase refresh remains outstanding. No FPS claim.Inherited title-side length comparisons (#11893, unchanged here). These are the earlier Windows-host calls into the bundled
libc.prxfrom PPSA07923 and PPSA13934, not new PS5 measurements. Both title libraries gave the following outcomes for the narrow and wide cases listed in #11893's Tested section:%Ldof the 32-bit0x89abcdefpattern-1985229329(int, notlong long)%hhcof0x44D%hfof1.51.500000%hpof pointer0x12341234a%Lnintcount of 1; the adjacent bytes remain unchangedThe parent report's narrow matrix covers
Lond/i/u/x/X/o/n, every length onc/s/n, the listed floating-length combinations andh/hh/ll/L/zonp; its explicitswprintfset is%Ld %Lx %hf %zg %hp %Lp %hhc %Lc %hhs %Ls %hs %Ln. Each new expectation was checked against both bundled libraries. #11893's follow-up tests use the matchingint/guarded-intargument types.The actual parent is updated #11907
8cac89f55a87191359f990f27952ecc1dd3cfbfeon maina4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8. Earlier #11893/#11907 pins below describe historical measurements, not ancestry claims for this linear rebase. Against #11907, this PR adds onlyStoApplicableLength's pointer-like case; the%Ld/%hhc/%hf/%hp/%Lnbehavior is inherited unchanged. The%hS/%lSmeasurements for this PR remain separately listed above. Positional formats remain a CPU regression check, rather than a new title-side measurement.Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON, on #11907's head15b33e8e76.libc.prx: I loaded PPSA07923's and PPSA05916'slibc.prxnatively and called theirsnprintfby NID (eLdDw6l0-bU) side by side with this build. Over 31 format/argument pairs (the table above, plus%ls/%lc/%Swith units 0x7F to 0xFFFF, lone surrogates and precisions 1 to 4), comparing the return value,errnoand the output bytes:%Cand a zero%lc); the other 14 hit 2 more differences (%5C,%-3C) and then abort at%hC;swprintfagainst the titles (NIDnJz16JE1txM), 28 pairs: the 11%C/%S/unknown-conversion differences go to 0; the 6 left are the high-byte%c/%srows that #9964 and #9953 cover. Negative control: with #11907'sFormattingWide.cpp,guest_wide_formattingfails.guest_formatting,guest_wide_formatting,guest_stdio_variadicandguest_scan_countpass in each of 3 runs.WindowsFormatting.hpp,guest_formattingfails.Not tested on Linux or macOS. On Linux,
RequiresGuestFormattingalready sends formats with%Cand%lcto the same formatter, and now%hS/%lStoo, sinceApplicableLengthchanges their length.Overlap:
tools/pr_overlap.pylists the PRs that overlap #11893 and #11907, whose commits come first here. For this commit's own lines it reports only #11733 and #11737, which add debt entries next to the narrow-printf one; neither edits that entry.Review correction and inherited evidence (2026-10-28)
@MarcZX10 Fixed the positional
%Cargument read ind017d6a6a4da133ee82577db92df03abaa5d4b66.Cis now absent fromNumberedArgumentClassesas well asKnownConversions. The regression uses%1$C,%2$C,%1$hCand padded%1$5Cwith validVaListdescriptors whose unused argument-storage pointers are null, checking both register and overflow paths, the output and that the caller's descriptor is unchanged.%1$C%dwith one integer must print%C7.Linux x86-64, Arch Linux 7.2.9, Ryzen 9 7950X, GCC 16.2.1, Ninja Release: all four groups (
guest_formatting,guest_wide_formatting,guest_stdio_variadic,guest_scan_count) pass three times on the original reviewed head and three times on the fixed head (12/12 each, zero skips). With only the new regression and the old classifier,guest_formattingfaults on the eager argument read; the other three groups pass. Conventions and whitespace checks pass. This is CPU validation, not a new title-side measurement of positional formats.The ignored-length cases are inherited from #11893, rather than introduced here: historical head
17c950f0a54f8e44ec1e7561034ab6d7086ef824supplied the measured basis through #11907 at15b33e8e763cc814c74aa122a83b34c8cf8fe25e. #11893's Tested section records the earlier Windows comparisons with PPSA07923 and PPSA13934: the narrow length matrix, plus wide%Ld %Lx %hf %zg %hp %Lp %hhc %Lc %hhs %Ls %hs %Ln. Comparing this PR with #11907 changesApplicableLengthonly forS, whose%hS/%lSmeasurements are already listed here. The inherited length behavior and its secure-format debt remain intact.AI-assisted: yes (Codex).
Exact patch, source/dependency proofs, inherited measurements, original/test-only/fixed logs and JUnit, SHA-256
a535eeb4a7654869751db4be670d15c91bd2c9c1e0a03953ca2ee915f4bf1633. Please re-review the fixed classifier and the existing parent measurements. No new Windows, macOS or console measurement is claimed.Current Linux qualification — 2026-10-29
Integrated current
main157b02c4f1803e9d2cd757677b9a805961203fc4by normal fast-forward merge; earlier measured fixes, tests and actual parent ancestry are retained.New head:
078102a03f127cd5dee128d1244195d4034916e4. The merge is automatic. The precision/width and positional unknown-conversion regressions remain, alongside main’s tests and entry-point calls.Linux Release:
guest_formatting,guest_wide_formatting,guest_stdio_variadic,guest_scan_countpass three repetitions (12 checks), plus the public-header audit, zero skips. ActualFormatting.cppandFormattingWide.cpp, includingWindowsFormatting.hpp, pass MinGW GCC16.2.0 cross syntax checking. Conventions report zero errors; any debt-length warnings are preserved in the logs. Whitespace and recursive submodule-pointer checks pass.This is current-main Linux integration and Windows cross-compilation syntax evidence. Earlier actual Windows/title-library measurements retain their historical pins; no new Windows runtime, macOS, title, GPU or performance result is claimed. AI-assisted: yes.
Evidence: immutable Linux qualification bundle. Its SHA-256 is
ca6b35926bcc6d3f21a9650517894c86b65594e2e2b653c5c32cd1c1de89c835. No fresh Windows runtime execution is claimed; older measurements retain their recorded source pins.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-28T12:27:36Z.
Review: CHANGES_REQUESTED
The measured narrow-format behavior is well evidenced, but two parts of this diff remain unsettled:
KnownConversionsno longer containsC, andFormatWindowsnow prints%Cwithout taking an argument, butNumberedArgumentClassesstill classifiesCas an integer conversion ("diouxXcCsSpn"). It eagerly fetches all classified positional arguments inFormatArguments::NumberbeforeFormatWindowshandles the conversion. Thus a positional%1$Cis still treated as requiring/fetching an argument even though the measured narrow%Cconsumes none; the existing positional test was changed to avoid this case and the PR says positional%Cis unmeasured. Please removeCfrom that classifier or make positional%Cfail conservatively until measured, and add a regression that pins the chosen behavior.The hardware comparison described here calls the titles’
snprintfNID. The diff also changes the separateFormatWide/swprintfpath: it now ignores previously rejected lengths and prints unknown conversions rather than throwing.GuestWideFormattingtests encode these new outcomes, but I could not find a title-sideswprintfcomparison or other source for them. Please provide that evidence, or keep the wide changes at their previous conservative behavior and record the remaining wide-format gap as debt until measured.Exact-head diff check, conventions, and test-registration checks pass (202 scripts). The Windows title-side and formatter evidence in the PR is useful for the narrow path; hosted checks for this head are still pending. I have not approved.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T12:37:14Z.
Review: CHANGES_REQUESTED
Follow-up on exact head
0e1fc1e540baf0a466f8068839967b8b4599cedc. The new title-sideswprintfcomparison addresses my earlier wide-format evidence request. Two issues remain:In
core/libs/prx/libc/include/WindowsFormatting.hpp,KnownConversionsnow excludes uppercaseC, soFormatWindowsprints%Cwithout consuming an argument, butNumberedArgumentClassesstill classifiesCas an integer in"diouxXcCsSpn".FormatArguments::Numbereagerly fetches every classified positional argument before formatting. Thus a positional%1$Cstill reads an argument even though%Cis handled as non-consuming; the changed positional test avoids this case. Please removeCfrom that classifier (or conservatively reject positional%C) and add a regression that pins the intended no-consumption behavior.This update adds
ApplicableLengthbehavior for unsupported length/conversion combinations in both narrow and wide formatting (%Ld,%hhc,%hf,%hp,%Ln, etc.). The PR's stated title comparisons cover%C,%lc,%Sand unknown conversions, but I don't see a title-side measurement for those ignored-length cases. Unit expectations alone don't establish console behavior. Please provide matching title-side evidence for the new length cases and updateTested, or keep this change limited to the measured conversions and retain the previous conservative behavior for unmeasured combinations.I have not run the formatter binaries locally: this worktree has no configured build tree, and the registration audit only confirms that 202 test scripts are registered.
git diff --check, conventions and the script-registration audit pass. Hosted checks are pending; I am not approving.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T12:49:36Z.
Review: CHANGES_REQUESTED
Follow-up on the new head : the positional-argument issue is fixed. Removing from and the new // regressions now match the stated non-consuming unknown-conversion behavior.
The other evidence gap remains: this PR changes for unsupported length/conversion combinations in both narrow and wide formatting. The title-side examples listed in the body cover // and /, but not combinations such as , , , or . The unit expectations alone do not establish the titles' behavior for these newly accepted formats. Please add title-side comparisons for the behavior being changed, or keep the previous conservative error path for combinations without evidence and cover the measured cases with regressions. I did not run the formatting binaries locally; the added regression source has not been executed in this review. No approval.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T00:17:13Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The updated test and title-comparison evidence addresses the earlier review questions, but the current head conflicts with
mainin the libc debt file and needs an integration rerun.What I ran
Reviewed exact head
f2548977ea559a13c157c8ad0e5109983745dccd, whose merge base with currentmainis8ff4baf53489033dae79090640143e82d159ee4d. The merge preview onto currentmain3a2b91981651569163768854a1fcdc7193b6667bconflicts indocs/dev/debt/libc.md. I inspected the exact-head formatting implementation and regression diff. Environment: Linux x86-64, Git and GitHub CLI. I did not build or run tests locally.Results
docs/dev/debt/libc.mdguest_formattingandguest_wide_formattingpass 3/3 on this head%C,%S,%yand inherited length cases on their stated Windows-host title librariesCommand output
The PR body records
Depends on: #11907 (and through it #11893); both remain open. Keep that order while resolving the current-main conflict.Negative control
swprintf%5Scase; candidate has 0 differences over the reported 37-format copy-rule set. I did not reproduce this comparison locallyFindings
Blocking
main:docs/dev/debt/libc.mdconflicts. Resolve the debt entry against current text, keep the recorded #11907 → #11893 dependency chain, and rerun the exact focused tests on the rebased head. The current test/comparison evidence is from older bases.Non-blocking
%Cargument and title-evidence questions. I did not find an additional defect in the reviewed diff.%.1lcconcern is not established by the newly changed behavior here; this PR's%lcchange is the zero-character path. I am not treating that comment as a blocker for this head.Sources
Not verified
To get this to a good state
Rebase onto current
main, resolve the debt entry, preserve the stated dependencies, and rerunguest_formattingandguest_wide_formattingon the new head. Record the exact base and head. I will re-check the merged diff and repeat the focused validation available here.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:26:49Z.
Review: CHANGES_REQUESTED
Re-reviewed — changes requested
The new
%lcprecision fix and added cases address the formatting issue raised in the thread. The title-side matrix and negative-control results are useful: they cover the length/conversion pairs and report all 48 comparisons matching both reference libraries. The focused Linux and Windows runs are also materially stronger than the earlier report.What I checked
41cfd4560a227a30c4848186ba6b8568998835e6.main:bc3e33f4e334996ab9ba5cbf8544942465be18f3.git merge-tree --write-treeis otherwise clean but conflicts indocs/dev/debt/libc.md.git diff --checkpasses andtools/check_conventions.pypasses against currentmain.%lc, byte-based width and ignored%lcprecision.Still blocking
Please resolve the current debt-file conflict while retaining the entries from both
mainand this PR, then rerun the focused formatting suites on that integrated head. The posted Linux/Windows candidate-library results address the behavioral comparison, but the branch still has not been validated after integrating today'smain.I found no additional source defect in the new
%lcfix on inspection. I will reassess after the integration check.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T13:36:51Z.
Review: APPROVED
Re-checked — new head, looks good
The new head resolves the debt-file conflict, preserves the measured formatting changes, and includes an exact-head Windows rerun with a negative control.
What I ran
078102a03f127cd5dee128d1244195d4034916e4against currentmaindfcc0e17cb254d08fec9ec120e362620795d59a0; the merge preview is clean.95137178d026with the PR file list; no PR files changed in that interval.git diff --check upstream/main...refs/remotes/review/pr-12397; it passed with no output.Results
main1f79a818608bd391470cb8472eac564da0f1e637guest_formattingandguest_wide_formattingUnedited command output
Negative control
Findings
Blocking
None found in the reviewed head.
Non-blocking
The exact-head focused Windows run is author-reported, not independently reproduced. Hosted product Windows is still pending; Linux product tests are skipped.
Sources
Not verified
I did not independently run Linux, macOS, console, or firmware formatting tests, and I did not rerun the GTA/reference comparisons. The author's Windows run and title observations are reported evidence.