https://bugs.winehq.org/show_bug.cgi?id=49378
Bug ID: 49378 Summary: kernel32.WriteFile with multi byte characters reports incorrect number of written bytes Product: Wine Version: 5.10 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: minor Priority: P2 Component: kernel32 Assignee: wine-bugs@winehq.org Reporter: suokkos@gmail.com Distribution: ---
Created attachment 67438 --> https://bugs.winehq.org/attachment.cgi?id=67438 Wine test case to trigger the bug
Writing utf-8 multibyte characters to stdout using stdio led to uncovering this bug. Attached test case is a simple way to trigger the underlying issue.
Minimal steps leading to issue: 1. Set console output to CP_UTF8 2. Use WriteFile with multibyte characters
Expect outcome: WriteFile reports number of bytes written.
Actual outcome: WriteFile reports number of characters written.
Other observations while writing test case: I first run same test case using kernelbase.WriteFile. Base version seems to behavior differently because my test case passed. I only then noticed the important detail that there is multiple WriteFile entry points.
https://bugs.winehq.org/show_bug.cgi?id=49378
--- Comment #1 from Rafał Mużyło galtgendo@o2.pl --- ...it might be completely unrelated, but (mentioned this awhile ago on irc) I've recently ran into an interesting case: a Unity game, that was crashing due to 'address space exhaustion', that before the crash was printing a stack trace several times.
The potentially relevant part is that the game was run under LANG=ja_JP.utf8 and the stacktrace contained mojibake...
...but only if run as 'LANG=ja_JP.utf8 wine <executable>', if I redirected the log via 'LANG=ja_JP.utf8 wine <executable> 2>&1 | tee crash.log', both the crash log and the console output were mojibake-free.
https://bugs.winehq.org/show_bug.cgi?id=49378
--- Comment #2 from Pauli Nieminen suokkos@gmail.com --- (In reply to Rafał Mużyło from comment #1)
...it might be completely unrelated, but (mentioned this awhile ago on irc) I've recently ran into an interesting case: a Unity game, that was crashing due to 'address space exhaustion', that before the crash was printing a stack trace several times.
If output uses stdio then https://source.winehq.org/patches/data/186903 is a potential fix for multiple prints from a buffered stdio output. The patch was a response to a related issue report at mailing list.
But even with that patch I can see some output errors from buffered stdio. I think there is more work to be done for stable multibyte output using msvcrt stdio. But issues are relative minor after patch 186903 and fix for this bug.
It is easy to make a hack fix for this bug. Proper fix would be fairly easy using mbrlen or mbrtowc. But I think those aren't available in kernel32.dll.
https://bugs.winehq.org/show_bug.cgi?id=49378
François Gouget fgouget@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |source, testcase CC| |fgouget@codeweavers.com