Skip to content

Leaking tasks when aborting HTTP/2 Connections #51307

Open
@amcasey

Description

@amcasey

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When lots of connections are aborted very quickly, a few of them get stuck in this loop waiting on tasks that never terminate. The remaining (unscheduled) tasks are

Microsoft.AspNetCore.Server.Kestrel.Core.dll!Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2Connection.ProcessRequestsAsync<Microsoft.AspNetCore.Hosting.HostingApplication.Context>(Microsoft.AspNetCore.Hosting.Server.IHttpApplication<Microsoft.AspNetCore.Hosting.HostingApplication.Context> application) Line 409
Microsoft.AspNetCore.Server.Kestrel.Core.dll!Microsoft.AspNetCore.Server.Kestrel.Core.Internal.HttpConnection.ProcessRequestsAsync<Microsoft.AspNetCore.Hosting.HostingApplication.Context>(Microsoft.AspNetCore.Hosting.Server.IHttpApplication<Microsoft.AspNetCore.Hosting.HostingApplication.Context> httpApplication) Line 109
Microsoft.AspNetCore.Server.Kestrel.Core.dll!Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware.OnConnectionAsync(Microsoft.AspNetCore.Connections.ConnectionContext context) Line 227
Microsoft.AspNetCore.Server.Kestrel.Core.dll!Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.KestrelConnection<Microsoft.AspNetCore.Connections.ConnectionContext>.ExecuteAsync() Line 69
Microsoft.AspNetCore.Server.Kestrel.Core.dll!Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2FrameWriter.WriteToOutputPipe() Line 149
System.Private.CoreLib.dll!System.Threading.Tasks.Task.Run

The second is somewhat irrelevant as it's just waiting for the connection to go away.

The object being awaited is a StreamCloseAwaitable, which is somehow reused for multiple streams in a single connection in a way I have yet to comprehend.

Expected Behavior

No response

Steps To Reproduce

The repro I'm aware of is a simulated Rapid Reset attack.

Exceptions (if any)

No response

.NET Version

8.0 RC2 and, presumably, main

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    HTTP2area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions