Certain invalid UTF-8 sequences can cause the output to fail #5734

Closed
opened 2026-01-31 00:20:20 +00:00 by claunia · 3 comments
Owner

Originally created by @j4james on GitHub (Dec 30, 2019).

Environment

Windows build number: Version 10.0.18362.418
Windows Terminal version (if applicable): 0.7.3451.0

Steps to reproduce

  1. Open a bash shell.
  2. Execute the command printf "\xA3"

Expected behavior

I'd expect to see something like the U+FFFD error character, or worst case nothing at all.

Actual behavior

The output is aborted with an error:

-bash: printf: write error: Input/output error

This looks similar to issue #3320, but PR #3380 doesn't fix it, and a recent build from master still produces the problem.

I did a bit of experimenting, and if you replace the MB_ERR_INVALID_CHARS with 0 in the _ParseFullRange method, that seems to help, although I don't know whether that's the right solution.

I know there was a follow up task created which may end up fixing this (#3378), but I thought it best to have the issue filed as an actual bug. If you don't think that's necessary, though, you can always close this as a dup.

Originally created by @j4james on GitHub (Dec 30, 2019). # Environment Windows build number: Version 10.0.18362.418 Windows Terminal version (if applicable): 0.7.3451.0 # Steps to reproduce 1. Open a bash shell. 2. Execute the command `printf "\xA3"` # Expected behavior I'd expect to see something like the U+FFFD error character, or worst case nothing at all. # Actual behavior The output is aborted with an error: -bash: printf: write error: Input/output error This looks similar to issue #3320, but PR #3380 doesn't fix it, and a recent build from master still produces the problem. I did a bit of experimenting, and if you replace the `MB_ERR_INVALID_CHARS` with 0 in the [`_ParseFullRange`](https://github.com/microsoft/terminal/blob/126d489af97fdafbb3194c0cd32f9f99b031f376/src/host/utf8ToWideCharParser.cpp#L296) method, that seems to help, although I don't know whether that's the right solution. I know there was a follow up task created which may end up fixing this (#3378), but I thought it best to have the issue filed as an actual bug. If you don't think that's necessary, though, you can always close this as a dup.
Author
Owner

@german-one commented on GitHub (Jan 1, 2020):

#4093 could be a first step. I'm quite certain the functions and classes could be used to update Utf8ToWideCharParser in a proper way.

@german-one commented on GitHub (Jan 1, 2020): #4093 could be a first step. I'm quite certain the functions and classes could be used to update `Utf8ToWideCharParser` in a proper way.
Author
Owner

@j4james commented on GitHub (Jan 2, 2020):

@german-one I'm a bit confused. Is #4093 still a work in progress, or is it not intended to replace the conhost utf8 parser yet? I was hoping I could just merge your PR and it would fix the problems I was seeing, but that doesn't seem to be the case.

@j4james commented on GitHub (Jan 2, 2020): @german-one I'm a bit confused. Is #4093 still a work in progress, or is it not intended to replace the conhost utf8 parser yet? I was hoping I could just merge your PR and it would fix the problems I was seeing, but that doesn't seem to be the case.
Author
Owner

@german-one commented on GitHub (Jan 2, 2020):

It's intended to be the first step. My implementation is able to supersede Utf8ToWideCharParser entirely. And indeed that's the next item on my list. But first I want to get the hand-rolled conversions reviewed by the core contributors. Unifying the UTF-8 parsers is too much for only one PR I guess.

@german-one commented on GitHub (Jan 2, 2020): It's intended to be the first step. My implementation is able to supersede `Utf8ToWideCharParser` entirely. And indeed that's the next item on my list. But first I want to get the hand-rolled conversions reviewed by the core contributors. Unifying the UTF-8 parsers is too much for only one PR I guess.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5734