-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenConsole crash when pasting emoji #8663
Comments
Irrespective of whether emojis are expected to work in these conditions, it seems very wrong to me that an error condition here would cause the entire process to terminate. I'm convinced that half of the |
I cannot reproduce the crash when right-click pasting 😀 (U+1F600) or 👨👩👧👦 (U+1F468 U+200D U+1F469 U+200D U+1F467 U+200D U+1F466) to OpenConsole.exe copied from Windows Terminal 1.4.3243.0, with the demo program built for x86, on Windows 10 version 20H2 (19042.685), where the setting "Beta: Use Unicode UTF-8 for worldwide language support" is off. I don't see why SetFileApisToANSI would even matter here; doesn't it only affect the encoding of file names, which the demo program does not use? |
@KalleOlaviNiemitalo I think you need to paste more than 100 characters (the length of the 😀💘💥👍🎅🦄🍄🌎🚖⚓🚀⌚💣😀💘💥👍🎅🦄🍄🌎🚖⚓🚀⌚💣😀💘💥👍🎅🦄🍄🌎🚖⚓🚀⌚💣😀💘💥👍🎅🦄🍄🌎🚖⚓🚀⌚💣😀💘💥👍🎅🦄🍄🌎🚖⚓🚀⌚💣 |
I have been using a single 😁 to crash it. |
In that case I can't reproduce it either. What's the commit hash of the revision that you're testing with? And in case it makes any difference, what are the build details - x86 or x64, debug or release? Also, what keyboard locale are you using? |
I just realised that the crash that I was seeing was actually in the This is in terminal/src/host/readDataDirect.cpp Lines 168 to 184 in d09fdd6
And this is in terminal/src/host/directio.cpp Lines 226 to 242 in d09fdd6
Either of those will crash if the number of |
If I understand correctly, InputBuffer::_ReadBuffer tries to predict how many UTF-16 input events fit in the specified number of OEM input events, but it assumes the OEM encoding uses at most two bytes per character: terminal/src/host/inputBuffer.cpp Lines 394 to 405 in d09fdd6
According to #7589 (comment), the estimated number of bytes per character even depends on the font. Then, SplitToOem translates the UTF-16 input events to OEM input events. If the configured code page is UTF-8, then it uses CESU-8, which may need three bytes per UTF-16 code unit. _DoGetConsoleInput cannot return the excess events to its caller and does not know how to put them back to the input buffer, either. If InputBuffer::_ReadBuffer supported UTF-8, then that would avoid the crash, I think. However, the resulting input events would still have CESU-8 rather than UTF-8, unless that is converted in some other layer that I cannot find now. Also, I wonder if the StoreReadPartialByteSequence call should perhaps be skipped if IsPeek is true. |
dangit, I can't reproduce it any more with my simple piece of code. The more involved repro consists of running code in this branch https://github.com/amoldeshpande/tcsh/tree/unicode under Windows Terminal or OpenConsole.exe and pasting the emoji. This is 100% still repro-able with font of "MesloLGM NF" . Have not tried any other fonts IIRC with this shell. (Nerd Fonts from here https://github.com/ryanoasis/nerd-fonts/releases) In answer to a previous question, I used an x64 debug build with standard US-EN keyboard layout. I will keep trying to make my simple repro crash again meanwhile. |
My guess is that there was a mode change involved somewhere (i.e. |
|
Okay since it looks like there's a repro and a pretty well identified piece of code responsible, I'm yanking triage. Looks like we didn't end up getting to this in 1.7, so I'm just gonna throw in with 2.0. Thanks everyone! |
Hey uh, is anyone still hitting this? I can't get this to repro anymore as of |
I can't even compile main because of missing |
You need to update your submodules. |
I can still reproduce a crash on a recentish build of OpenConsole (90ff261), but as I mentioned above, my crash is in To reproduce, I'm using this little test app in a conhost cmd shell:
And once it's running I paste a bunch of emojis like this: |
after an hour of compiling it now claims I don't have a .NET SDK installed. I'm tired of this crap. You can close the bug if you like. The repro I gave is pretty simple (you can use any current release of tcsh) and if it doesn't crash, consider me satisfied. |
Hmmmmmm. So it sounds like we kinda need to do a |
Okay so I think
Both do the same thing. If called with Wow those two functions are really basically the same code aren't they... |
Environment
The text was updated successfully, but these errors were encountered: