Repository navigation
fix(libc): format 16-bit wide arguments in asprintf on Linux - #3978
Merged
oneandonlydean merged 1 commit intoOct 12, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ha6Tsy62AFUyp9a5Mf7vjA
9 tasks done
10 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On Linux, the narrow printf functions send a format that has a guest wide conversion (
%ls,%lc,%S,%C) to the guest formatter, which reads 16-bit characters. Onlyasprintf(AllocatingStrings.cpp) gave every format to the host'svasprintf. The host reads a 32-bitwchar_tper character, so a guest UTF-16 string came out wrong, or the call failed. Windows was not affected.asprintfnow forwards its arguments tovasprintf, asfprintfdoes withvfprintf.vasprintfalready chooses the formatter and copies the result into the application heap. The null-argument checks and the out-of-memory result are the same as before.Tested
Ubuntu 24.04, GCC 13.3, on
main12c22662.guest_formatting: a new check registers an application heap and callsasprintf("%ls:%S:%lc:%d", u"é", u"ab", 0x20ac, 7). It expects 11 and the UTF-8 texté:ab:€:7, then frees the result with the guestfree.mainwithout the change and passes with it.guest_wide_formattingpasses.vasprintf, which makes the sameFormatWindowscall thatasprintfmade before.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (n/a).mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01Ha6Tsy62AFUyp9a5Mf7vjA