-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Decreasing the window size below the amount of data sent can prematurely abort the connection #47452
Comments
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Moving to backlog. This is a low-pri bug, only affects an edge case in the HTTP/2 spec and only sometimes since it's a race. |
We are encountering this issue intermittently after we upgraded our service from .NET 6 to 8.
Our service is a grpc server that provides streaming calls to transfer large volumes of data. The grpc client in our case is written in C++. After the error, the grpc client is not notified of any errors, and it remains waiting for a response. |
The following error can occur in specific scenarios if the server has sent some data on a stream and the client updates the window size to some value below the amount already sent
Method 1
For example, if the server sends 2 bytes with an initial window size of 3, then the client updates the window to be 1. The server will successfully have scheduled a new item to the output loop for processing:
aspnetcore/src/Servers/Kestrel/Core/src/Internal/Http2/Http2OutputProducer.cs
Lines 312 to 314 in 7aca303
But before it starts processing the item in
aspnetcore/src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs
Lines 111 to 117 in c93d0d0
The updated Window can be processed:
aspnetcore/src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs
Lines 891 to 897 in ff6c5e7
Which will decrease the
_streamWindow
to a negative value, which will then fail the buffer slice ataspnetcore/src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs
Lines 131 to 139 in c93d0d0
Method 2
Another way this can be hit is if
Stop
is called once the_streamWindow
is negative, even if nothing has been scheduled yet, because it will callSchedule
itself without any checks for_streamWindow
aspnetcore/src/Servers/Kestrel/Core/src/Internal/Http2/Http2OutputProducer.cs
Lines 566 to 583 in ff6c5e7
Method 3
Doing multiple writes can also cause this, if the window update happens after the first write, but before the second one (or if it happens during the race between starting to process the second write and reading the settings as described in method 1).
This path also calls
Schedule
without a check for_streamWindow
.aspnetcore/src/Servers/Kestrel/Core/src/Internal/Http2/Http2OutputProducer.cs
Lines 388 to 407 in ff6c5e7
This following test will hit the issue in either the
Stop
path described in method 2 or the multi write path described in method 3.The text was updated successfully, but these errors were encountered: