[7.0] Fix reporting of an async IO timeout error on Windows (SerialPort)#81745
Merged
carlossanlop merged 1 commit intodotnet:release/7.0from Feb 9, 2023
kouvel:NtStatusFix7
Merged
[7.0] Fix reporting of an async IO timeout error on Windows (SerialPort)#81745carlossanlop merged 1 commit intodotnet:release/7.0from kouvel:NtStatusFix7
SerialPort)#81745carlossanlop merged 1 commit intodotnet:release/7.0from
kouvel:NtStatusFix7
Conversation
…ort`) - Port of #81744 - When an async `SerialPort` IO operation times out, it reports the timeout in the IO completion with an `NTSTATUS` value of `WAIT_TIMEOUT` (258) - In the thread pool when using `GetQueuedCompletionStatusEx`, the `NTSTATUS` value was being checked against `STATUS_SUCCESS` to determine success, so the `WAIT_TIMEOUT` was reported as an error. This leads to a different exception being thrown, compared to before when `GetQueuedCompletionStatus` was used. - Fixed to use similar logic to the SDK's `NT_SUCCESS` macro, which treats the `WAIT_TIMEOUT` value as a success, which is similar to what `GetQueuedCompletionStatus` does - There are already tests that verify this behavior in `System.IO.Ports` tests, though [they are currently disabled](https://github.com/dotnet/runtime/blob/b39d6a6eb44860746e91e5ce4f585beff33d1f63/src/libraries/System.IO.Ports/tests/Support/TCSupport.cs#L108-L118) due to instabilities. I have verified locally that the relevant failures are fixed and that there are no new failures in those tests. Relevant to #80079
|
Tagging subscribers to this area: @mangod9 Issue Details
Port of fix for #80079
|
jeffschwMSFT
approved these changes
Feb 7, 2023
Member
jeffschwMSFT
left a comment
There was a problem hiding this comment.
approved. we will take for consideration in 7.0.x
mangod9
approved these changes
Feb 8, 2023
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SerialPort) #81744SerialPortIO operation times out, it reports the timeout in the IO completion with anNTSTATUSvalue ofWAIT_TIMEOUT(258)GetQueuedCompletionStatusEx, theNTSTATUSvalue was being checked againstSTATUS_SUCCESSto determine success, so theWAIT_TIMEOUTwas reported as an error. This leads to a different exception being thrown, compared to before whenGetQueuedCompletionStatuswas used.NT_SUCCESSmacro, which treats theWAIT_TIMEOUTvalue as a success, which is similar to whatGetQueuedCompletionStatusdoesSystem.IO.Portstests, though they are currently disabled due to instabilities. I have verified locally that the relevant failures are fixed and that there are no new failures in those tests.Port of fix for #80079
Customer Impact
A
SerialPortIO operation that times out raises anIOExceptioninstead of the documentedTimeoutException. Some customers have reported the issue and that it has broken several apps usingSerialPorton Windows. There is a runtime config option that can be configured to revert the change in behavior, which serves as a workaround. Another workaround is to catch theIOExceptionand check the error code.Regression?
Yes, from 6.0
Testing
Verified with the repro that the behavior is the same as before
Risk
Low. .NET 6 uses
GetQueuedCompletionStatus, and after the change the behavior is closer to whatGetQueuedCompletionStatusdoes.