FillConsoleOutputCharacterA crashes conhost when passed an invalid character #4258
Labels
Area-Server
Down in the muck of API call servicing, interprocess communication, eventing, etc.
Issue-Bug
It either shouldn't be doing this or needs an investigation.
Needs-Tag-Fix
Doesn't match tag requirements
Priority-1
A description (P1)
Product-Conhost
For issues in the Console codebase
Resolution-Fix-Committed
Fix is checked in, but it might be 3-4 weeks until a release.
Severity-Crash
Crashes are real bad news.
Milestone
Environment
Steps to reproduce
Compile and run the following C program in a conhost shell:
Expected behavior
I believe codepoint 14 is invalid in the given codepage, so I would expect it to write out something like the unicode replacement character in the top left corner of the screen buffer, or possibly nothing at all. The legacy console seems to write out a null character.
Actual behavior
The conhost crashes.
What's happening is that the
FillConsoleOutputCharacterAImpl
method is callingConvertToW
with a string that can't be converted in the given codepage. AndConvertToW
then throws an exception whenMultiByteToWideChar
returns 0.terminal/src/types/convert.cpp
Lines 41 to 42 in 9e5792b
And note that
FillConsoleOutputCharacterAImpl
is declared asnoexcept
, even though it quite clearly is capable of throwing exceptions. I've actually noticed a few cases like that - we may need to do an audit of ournoexcept
usage, and make sure it's being applied appropriately.The text was updated successfully, but these errors were encountered: