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

[QUIC] QuicStreamAbortedException sometimes is not thrown #53530

Closed
CarnaViire opened this issue Jun 1, 2021 · 1 comment · Fixed by #55309
Closed

[QUIC] QuicStreamAbortedException sometimes is not thrown #53530

CarnaViire opened this issue Jun 1, 2021 · 1 comment · Fixed by #55309
Labels
area-System.Net.Quic bug disabled-test The test is disabled in source code against the issue
Milestone

Comments

@CarnaViire
Copy link
Member

CarnaViire commented Jun 1, 2021

I found this while investigating pre-cancelled writes for #32077

This might be a result of a race condition, because I can see exception being set to ResettableCompletionSource, but it is not propagated to Read call.

It reproduces for me on this

        [Fact]
        public async Task StreamAbortedWithoutWriting_ReadThrows()
        {
            long expectedErrorCode = 1234;

            await RunClientServer(
                clientFunction: async connection =>
                {
                    await using QuicStream stream = connection.OpenUnidirectionalStream();
                    stream.AbortWrite(expectedErrorCode);

                    await stream.ShutdownCompleted();
                },
                serverFunction: async connection =>
                {
                    await using QuicStream stream = await connection.AcceptStreamAsync();

                    byte[] buffer = new byte[1];

                    // this assert fails (no exception was thrown)
                    QuicStreamAbortedException ex = await Assert.ThrowsAsync<QuicStreamAbortedException>(() => ReadAll(stream, buffer));
                    Assert.Equal(expectedErrorCode, ex.ErrorCode);

                    await stream.ShutdownCompleted();
                }
            );
        }

If I write anything to stream before aborting it, exception is thrown as expected.
I have just reproduced it after writing too.

I suspect it might be fixed by #52929 because @scalablecory mentioned fixing some race conditions for read state.

@ghost
Copy link

ghost commented Jun 1, 2021

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

Issue Details

I found this while investigating pre-cancelled writes for #32077

This might be a result of a race condition, because I can see exception being set to ResettableCompletionSource, but it is not propagated to Read call.

It reproduces for me on this

        [Fact]
        public async Task StreamAbortedWithoutWriting_ReadThrows()
        {
            long expectedErrorCode = 1234;

            await RunClientServer(
                clientFunction: async connection =>
                {
                    await using QuicStream stream = connection.OpenUnidirectionalStream();
                    stream.AbortWrite(expectedErrorCode);

                    await stream.ShutdownCompleted();
                },
                serverFunction: async connection =>
                {
                    await using QuicStream stream = await connection.AcceptStreamAsync();

                    byte[] buffer = new byte[1];

                    // this assert fails (no exception was thrown)
                    QuicStreamAbortedException ex = await Assert.ThrowsAsync<QuicStreamAbortedException>(() => ReadAll(stream, buffer));
                    Assert.Equal(expectedErrorCode, ex.ErrorCode);

                    await stream.ShutdownCompleted();
                }
            );
        }

If I write anything to stream before aborting it, exception is thrown as expected.

I suspect it might be fixed by #52929 because @scalablecory mentioned fixing some race conditions for read state.

Author: CarnaViire
Assignees: -
Labels:

area-System.Net.Quic

Milestone: -

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jun 1, 2021
@CarnaViire CarnaViire changed the title [QUIC] No exception on read if peer aborted stream without writing to it [QUIC] QuicStreamAbortedException sometimes is not thrown Jun 2, 2021
@karelz karelz added this to the 6.0.0 milestone Jun 3, 2021
@karelz karelz added bug and removed untriaged New issue has not been triaged by the area owner labels Jun 3, 2021
@ManickaP ManickaP added the disabled-test The test is disabled in source code against the issue label Jul 1, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Quic bug disabled-test The test is disabled in source code against the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants