Skip to content
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

Stream aborted if QuicStream.WriteAsync cancellation token is canceled after WriteAsync completes #82704

Closed
bentoi opened this issue Feb 27, 2023 · 2 comments · Fixed by #90253
Assignees
Milestone

Comments

@bentoi
Copy link

bentoi commented Feb 27, 2023

Description

A quic stream can be aborted even if the cancellation token provided to QuicStream.WriteAsync is canceled after WriteAsync completes.

Reproduction Steps

See attached test case.

quicabortread.zip

Expected behavior

Since WriteAsync successfully completed, it shouldn't trigger the stream abort if the cancellation token source is canceled after.

Actual behavior

Test case shows:

Unhandled exception. System.Net.Quic.QuicException: Stream aborted by peer (58).
   at System.Net.Quic.ResettableValueTaskSource.TryComplete(Exception exception, Boolean final)
   at System.Net.Quic.QuicStream.HandleEventPeerSendAborted(_PEER_SEND_ABORTED_e__Struct& data)
   at System.Net.Quic.QuicStream.HandleStreamEvent(QUIC_STREAM_EVENT& streamEvent)
   at System.Net.Quic.QuicStream.NativeCallback(QUIC_HANDLE* connection, Void* context, QUIC_STREAM_EVENT* streamEvent)
--- End of stack trace from previous location ---
   at System.Net.Quic.ResettableValueTaskSource.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.Quic.QuicStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 49
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 50
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 43
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 43
   at Program.<Main>(String[] args)

Regression?

No response

Known Workarounds

No response

Configuration

.NET SDK:
 Version:   7.0.200
 Commit:    534117727b

Runtime Environment:
 OS Name:     debian
 OS Version:  10
 OS Platform: Linux
 RID:         debian.10-x64
 Base Path:   /home/vagrant/dotnet/sdk/7.0.200/

Other information

No response

@ghost
Copy link

ghost commented Feb 27, 2023

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

A quic stream can be aborted even if the cancellation token provided to QuicStream.WriteAsync is canceled after WriteAsync completes.

Reproduction Steps

See attached test case.

quicabortread.zip

Expected behavior

Since WriteAsync successfully completed, it shouldn't trigger the stream abort if the cancellation token source is canceled after.

Actual behavior

Test case shows:

Unhandled exception. System.Net.Quic.QuicException: Stream aborted by peer (58).
   at System.Net.Quic.ResettableValueTaskSource.TryComplete(Exception exception, Boolean final)
   at System.Net.Quic.QuicStream.HandleEventPeerSendAborted(_PEER_SEND_ABORTED_e__Struct& data)
   at System.Net.Quic.QuicStream.HandleStreamEvent(QUIC_STREAM_EVENT& streamEvent)
   at System.Net.Quic.QuicStream.NativeCallback(QUIC_HANDLE* connection, Void* context, QUIC_STREAM_EVENT* streamEvent)
--- End of stack trace from previous location ---
   at System.Net.Quic.ResettableValueTaskSource.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.Quic.QuicStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 49
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 50
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 43
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 43
   at Program.<Main>(String[] args)

Regression?

No response

Known Workarounds

No response

Configuration

.NET SDK:
 Version:   7.0.200
 Commit:    534117727b

Runtime Environment:
 OS Name:     debian
 OS Version:  10
 OS Platform: Linux
 RID:         debian.10-x64
 Base Path:   /home/vagrant/dotnet/sdk/7.0.200/

Other information

No response

Author: bentoi
Assignees: -
Labels:

untriaged, area-System.Net.Quic

Milestone: -

@CarnaViire
Copy link
Member

Triage: I can reproduce that. We should address it in 8.0. Seems to be part of a group of issues around S.N.Quic's ResettableValueTaskSource (Cancellation, Reads/WritesClosed and disposal order/behavior).

@CarnaViire CarnaViire added this to the 8.0.0 milestone Mar 9, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Mar 9, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 9, 2023
@karelz karelz modified the milestones: 8.0.0, 9.0.0 Aug 14, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Sep 13, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants