Repository navigation
fix(libc): convert a wide printf %c like btowc, as titles' libc.prx does - #9964
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed the exact PR head 7868aaf against its declared dependency, #9953 at 8bffaa1. The implementation and tests cover the measured title behavior for narrow %c, including low-byte conversion, partial swprintf output, and the observed EILSEQ cases; I found no blocking issue in the diff.
I also overlaid the exact PR versions of FormattingWide.cpp and GuestWideFormatting.cpp (plus the debt update) into the existing configured Linux build tree, rebuilt guest_wide_formatting_tests, and ran ctest -R '^guest_wide_formatting$': 1/1 passed. This reused the existing build configuration and prerequisites rather than a fresh PR checkout. git diff --check and the repository convention checker against #9953 passed. Hosted Linux and Windows product jobs are skipped; the author's Windows differential and repeated focused-suite results are recorded in the PR description.
|
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.
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.
|
2e3e810 to
ef2bee9
Compare
|
Conflict refresh, 2026-10-27 UTC: exact head Linux Release focused libraries/executables rebuilt. Three groups (wide formatting, narrow formatting, public headers) each pass three times: 9 initial and 9 restored passes. Restoring only the #9953 parent production file fails the intended wide-formatting group; restored libc is byte-identical. Zero skips; conventions and whitespace pass. This is focused Linux evidence, without new Windows, console, title, GPU or full-suite validation. Earlier measurements retain their original exact pins. Source/dependency pins, production preservation, verbose build/test/control/restoration logs, JUnit, hashes and lease-push receipts. SHA-256: AI-assisted: yes. |
…on invalid UTF-8 The wide printf family decoded its narrow %s argument as UTF-8 of up to 4 bytes and fell back to Latin-1 for bytes that did not form a character. The libc.prx that titles ship decodes at most 3 bytes per character, accepts overlong forms and encoded surrogates, ends the string at a decoded NUL, and fails the whole call with EILSEQ on a byte that cannot begin a character, a 4-byte lead or an incomplete character, keeping the output written before that conversion. A precision stops decoding after that many characters but always decodes the first. Follow those rules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wide printf family wrote a narrow %c as the byte's own code unit, so 0xE9 became U+00E9. The libc.prx that titles ship converts the low byte of the argument as btowc does in its UTF-8 C locale: a byte below 0x80 is that character, and a byte of 0x80 or above fails the whole call with -1, keeping the output written before it and setting EILSEQ only for 0x80-0xBF and 0xF0-0xFF. Follow that, using the failure path the narrow %s already has. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ef2bee9 to
85de0b5
Compare
|
Main conflict refresh, 2026-10-27 10:18 UTC pass: exact head Linux Release focused rebuild: Narrow/wide formatting, stdio variadic and public headers each pass three times: 12 passes, zero skips. Conventions, whitespace and merge checks pass. Every refreshed head's submodule pointers match the pinned main; the private dependency checkouts used for the gates are aligned. No new negative-control, Windows, console, title, GPU, full-suite or performance run is claimed. Earlier measurements below retain their original exact pins. Fulfilled merge-order dependencies have been cleared from the checklist; open prerequisites remain. Exact source/dependency pins, patch-preservation and gitlink proofs, builds, verbose tests, JUnit and lease-push receipts. SHA-256: AI-assisted: yes. |
|
Integration note for the eventual rebase. I merged this PR locally with #11893, #11907, #12397 and #9953 on Conflict: it conflicts in
Result on Windows (WinLibs GCC 15.2.0 UCRT r7, Release):
AI-assisted: yes (Claude Code). |
|
Hi JJenkx, your #9953 merged today and this PR no longer merges cleanly with main. #9953 added a Could you merge main into this branch, build on the version #9953 put on main rather than adding a second one, and keep any tests of yours that #9953 doesn't already cover? A merge commit is fine; no need to rebase or force-push. Once it's pushed we'll re-review the merge. |
|
@oneandonlydean Main is merged, without a rebase or force-push. Head The resolution builds on #9953: one Fresh Linux Release build and focused checks: 4/4 pass, zero skips ( Logs, JUnit, resolved diff, exact pins and control receipts, SHA-256 Ready for re-review. AI-assisted: yes. |
What
The wide printf family wrote a narrow
%c(nol, or withh/hh) as the argument's low byte taken as a code unit, so 0xE9 became U+00E9. Thelibc.prxthat titles ship converts it the way itsbtowcdoes in the UTF-8 C locale (#8855 measures the samebtowc):Aand 0x100 gives U+0000;%sdoes, keeping the output written before the conversion;errnobecomesEILSEQ(86) only for 0x80–0xBF and 0xF0–0xFF. The valid lead bytes 0xC0–0xEF andEOF(-1) leave it alone.libc.prxmainx%cyof 0x80EILSEQ, bufferxx, U+0080,y[%3c]of 0xE9errnounchanged, buffer[%lc|%cof U+20AC, 0xFFEILSEQ, buffer€|[%c]of -1errnounchangedThis builds on the
WideEncodingErrorand booleanAppendUtf16decoder merged in #9953. The single error class retains main's message and partial output; its discriminator distinguishes%cfailures that preserve errno.%lcand%Cretain main's behavior.Tested
Current head
c22807ee5f65c395d0cca0d544a35d2bd669541fmerges main4f64f81ef7b4bca975b4b9f3dfd15dfff56f716finto the existing PR, as requested. No rebase or force-push.Linux, Release, independent fresh source/dependency checkout and configuration; built
guest_wide_formatting_tests,guest_formatting_testsandguest_stdio_variadic_testswith their full libc dependency.guest_wide_formatting,guest_formatting,guest_stdio_variadicandpublic_headerspass 4/4, zero skips.Negative control on prior merge
2c8453337e(candidate formatting source and fixture, and main control source, unchanged in this refresh): the same frozen wide-formatting executable fails at%c of a continuation byte fails with EILSEQwith onlyFormattingWide.cppreplaced by current main's version. Restoring the candidate rebuilds libc byte-for-byte identically; the four checks pass again. Conventions, whitespace and clean-worktree checks pass.Linux logs, JUnit, resolved diff and hashes, SHA-256
a6ec6ec866ade26fd53db504dcdd0c4d9514463ebc5ad6c17a3d881b80d2cce9.Earlier reference measurements on Windows 11/WinLibs GCC15.2 at head
7868aaf64aagainst #9953 head8bffaa164a: 44%ccases match the bundledlibc.prx(24 differences on the old main), and a 349,085-format sweep has no differences on PPSA07923/PPSA05916/PPSA13934 (2,843 old-main%cdifferences). These remain historical measurements of the byte-conversion rule, not a new Windows run of this merge. Console execution and streamed/secure%cerror output remain unverified in debt.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)