-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Fix FillConsoleOutputCharacterA crash #4309
Fix FillConsoleOutputCharacterA crash #4309
Conversation
So, fortunately, you actually can test this. The functions that are in Are there any other callers of |
@zadjii-msft thanks for the info on testing, and a good thing too. Inside I haven't done a pass for other |
I'll take a closer look at the crash this weekend. School has been eating up all my time this week. |
Here's the crash: @zadjii-msft, with the latest commit the repro no longer crashes. I did a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cools, thanks for the clarifications!
The important part is the final parameter, The MB2WC function should happily work with both counted and null-terminated (z) strings.
See, I don't know about this. I swear it won't walk past the count that it's given for the source parameter. It will if the count was
I think adding the try-catch block here is definitely warranted. It would probably harm nothing to just function-level TRY the whole method instead of having to declare the string outside the try and then use fill it later. Finally, I think we're going to need a test here that confirms the error code coming back from an invalid/unconvertible input character is the same error code that the v1 console gave. I'd want to see that in feature tests. Given that this is a bit weird in that you are seeing a crash that I cannot believe exists, I'd like to try to repro this myself. If I can get some time... |
OK I adapted the original repro scenario from #4258 into a feature test. I ran it against conhost v1 and this was the behavior:
I also reproduced the crash against v2. We should likely match the v1 behavior, beyond just fixing the crash, if it isn't matching. Will continue looking. |
Interesting that there's this discrepancy between v1 and v2. I'll take some time this weekend to have another look. Thanks for the v1 repro scenario, @miniksa, I'll try and get the behavior to match it. |
@mkitzan, I'll keep looking now. And upload the test. We can merge our two together to fix it. |
EDIT: Run by:
|
Part of the problem here also seems to be that So then we call |
I'm going to try to debug the v1 host to see how it is coming to a different translation conclusion than the v2 one. |
OK. So the v1 host was awful here. It would do...
That's right. It didn't check if there was an error. It just tried it and then plowed ahead with the 0 value if it didn't work. That feels terribly bad. I think what we do here is update the test I just wrote to document the difference here, fix this so it doesn't crash (and returns an acceptable error), and then check it in and roll from there. |
Well that's something, eh? Sorry for being AWOL on this one recently: it's midterm season. |
Not a problem. As long as you don't mind me partying on your branch. |
Always up for a party, thanks for the help! |
OK I cannot comprehend why the test got back a 0x2 error code instead of the 0xffff I was expecting, but then I went to go figure out why all tests are being bad right now in #4490. So I'll get back to this. |
🎉 Handy links: |
🎉 Once again, thanks for the contribution! This pull request was included in a set of conhost changes that was just |
When the console functional tests are running on OneCoreUAP, the newly-introduced (65bd4e3, #4309) FillOutputCharacterA tests will actually fail because of radio interference on the return value of GLE. Fixes MSFT-28163465
When the console functional tests are running on OneCoreUAP, the newly-introduced (65bd4e3, #4309) FillOutputCharacterA tests will actually fail because of radio interference on the return value of GLE. Fixes MSFT-28163465
When the console functional tests are running on OneCoreUAP, the newly-introduced (65bd4e3, #4309) FillOutputCharacterA tests will actually fail because of radio interference on the return value of GLE. Fixes MSFT-28163465 (cherry picked from commit 4aecbf3)
Summary of the Pull Request
Despite being specified as
noexcept
,FillConsoleOutputCharacterA
emits an exception when a call toConvetToW
is made with an argument character which can't be converted. This PR fixes this throw, by wrappingConvertToW
in a try-catch_return.References
PR Checklist
Detailed Description of the Pull Request / Additional comments
Following the symantics of other
FillConsoleOutputCharacter*
the output paramcellsModified
is set to0
. The try-catch_return is also what other functions of this family perform in case of errors.Validation Steps Performed
The repro test in the issue uses this function as it exists in thewindows.h
library not the one present in the WT repo (by my understanding). Because of this, I have not been able to test that this change corrects the original repro.Original repro no longer crashes.