ReadConsole returns TRUE after CancelIoEx #17791
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.
Priority-1
A description (P1)
Product-Meta
The product is the management of the products.
Tracking-External
This bug isn't resolved, but it's following an external workitem.
zInbox-Bug
Ignore me!
Milestone
Windows Terminal version
Latest source
Windows build number
10.0.19045.4780
Other Software
No
Steps to reproduce
Code
Expected Behavior
The program reads the console input in a blocking way.
If there is no input, another thread issues CancelIoEx after 3 seconds.
Since the
ReadConsole
did not read anything, it should return FALSE:So the program should print
Result: 0
.Actual Behavior
ReadConsole
does not read anything, does not updateNumberOfCharsRead
, but returns TRUE.It also leaves the input in somewhat inconsistent state, which you can see by typing something after the cancellation: the first input will be discarded. I think this was already mentioned here: #12143 (comment).
The incorrect return value is much worse though: it is a common pattern to leave
NumberOfCharsRead
uninitialized, because eitherReadConsole
succeeds and initializes it, or it fails and it makes no sense to look there anyway.In the code above I initialized it, but if I didn't do so an uninitialized read would've occurred, from both
NumberOfCharsRead
andBuffer
.Notably the last error is correctly set to 995 -
ERROR_OPERATION_ABORTED
- "The I/O operation has been aborted because of either a thread exit or an application request.", but who checks the last error on successful calls?The text was updated successfully, but these errors were encountered: