Skip to content

[release/10.0] Fix h3 connection-level and stream-level abort locking - #69150

Merged
wtgodbe merged 1 commit into
release/10.0from
brecon/bp10
Sep 9, 2026
Merged

[release/10.0] Fix h3 connection-level and stream-level abort locking#69150
wtgodbe merged 1 commit into
release/10.0from
brecon/bp10

Conversation

@BrennanConroy

@BrennanConroy BrennanConroy commented Sep 8, 2026

Copy link
Copy Markdown
Member

Backport of #68102 to release/10.0

/cc @BrennanConroy @cincuranet

Fix h3 connection-level and stream-level abort locking

Description

Improve server reliability when using HTTP/3.

Fixes #68101

Customer Impact

Threads can get blocked resulting in more threads being created.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Follows similar pattern already implemented in HTTP/2

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

Copilot AI lite review requested due to automatic review settings September 8, 2026 17:55
@BrennanConroy BrennanConroy added feature-kestrel area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions labels Sep 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

AbortCore currently takes _completionLock and then calls ApplyCompletionFlag which also takes _completionLock, creating a re-entrancy risk (potential self-deadlock) in the updated locking scheme.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 High severity

New issues introduced by this change (1)
Severity Finding
High severity src/​Servers/​Kestrel/​Core/​src/​Internal/​Http3/​Http3Stream.csAbortCore takes _completionLock and then calls ApplyCompletionFlag(...), which also takes…
What changed in this PR

This PR backports a reliability fix for HTTP/3 stream abort paths in Kestrel by restructuring abort locking to avoid deadlocks between stream completion state and output writer locks, and by ensuring request finalization waits for in-flight abort side-effects before pooling/reuse.

Changes:

  • Move HTTP/3 abort side-effects (e.g., _http3Output.Stop() and transport teardown) to run outside the stream completion lock to avoid lock-order deadlocks.
  • Introduce an abort-completion signal (_abortCompletedTcs) so request finalization can await abort side-effects before disposing/pooling the stream.
  • Mark streams as Completed during finalization and ensure late aborts become no-ops once completion is set.
File Description
src/​Servers/​Kestrel/​Core/​src/​Internal/​Http3/​Http3Stream.cs Refactors abort and finalization synchronization to prevent deadlocks and avoid abort side-effects racing with stream pooling.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 186 to 190
var (oldState, newState) = ApplyCompletionFlag(StreamCompletionFlags.Aborted);

if (oldState == newState)
{
return;
@BrennanConroy BrennanConroy added the Servicing-approved Shiproom has approved the issue label Sep 8, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hi @BrennanConroy. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed.

@wtgodbe
wtgodbe merged commit 431ea3d into release/10.0 Sep 9, 2026
27 of 31 checks passed
@wtgodbe
wtgodbe deleted the brecon/bp10 branch September 9, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-kestrel Servicing-approved Shiproom has approved the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants