-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
76831-SystemNetQuicTestsQuicStreamTestsWriteCanceled_NextWriteThrows #92266
76831-SystemNetQuicTestsQuicStreamTestsWriteCanceled_NextWriteThrows #92266
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsFixes #76831. There was a data race between cancellation action firing (i.e. calling Abort()) and DisposeAsync() from the thread awaiting the cancelled Task. Consider following code {
await using QuicStream stream = await connection.AcceptInboundStreamAsync();
CancellationTokenSource cts = new CancellationTokenSource(timeout);
//....
await stream.WriteAsync(buffer, cts.Token);
} If the This PR fixes the above situation by holding a lock while servicing the cancellation action (Abort), which mutually excludes DisposeAsync from gracefully closing the stream at the same time.
|
I'm not sure this is still relevant after my last PR (#90253) in QuicStream, which reverted the order or calling abort and waking up the caller of the async operation:
runtime/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicStream.cs Lines 93 to 111 in 963954a
For write, we now also wait for SEND_COMPLETE in all cases, including cancellation. |
Closing, the bug was fixed by #90253 |
Fixes #76831.
There was a data race between cancellation action firing (i.e. calling Abort()) and DisposeAsync() from the thread awaiting the cancelled Task.
Consider following code
If the
cts
times out, then the last await throws, which makes execution leave the block and triggering theDisposeAsync
onstream
. This dispose does graceful stream close. Which is racing with Abort() being called from the timer thread which handles the cts timeout.This PR fixes the above situation by holding a lock while servicing the cancellation action (Abort), which mutually excludes DisposeAsync from gracefully closing the stream at the same time.