Skip to content

Fix h3 connection-level and stream-level abort locking - #68102

Draft
cincuranet wants to merge 3 commits into
dotnet:mainfrom
cincuranet:h3-abort
Draft

Fix h3 connection-level and stream-level abort locking#68102
cincuranet wants to merge 3 commits into
dotnet:mainfrom
cincuranet:h3-abort

Conversation

@cincuranet

Copy link
Copy Markdown
Contributor

Fixes #68101

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.

Pull request overview

This PR addresses a potential deadlock in Kestrel’s HTTP/3 stream abort paths when connection-level and stream-level aborts interleave with inline output flushing, and adds coordination to ensure abort side-effects complete before a stream is disposed/pooled.

Changes:

  • Refactors Http3Stream.AbortCore so only the completion-state transition occurs under _completionLock, with abort side-effects executed outside the lock to avoid lock-order deadlocks with Http3OutputProducer._dataWriterLock.
  • Adds an abort-completion TaskCompletionSource and a CompleteAndWaitForAbortAsync() helper so request finalization can await in-flight abort side-effects before disposal/pooling.
  • Updates request finalization to mark the stream completed earlier and wait for any in-flight abort prior to draining/disposing the transport.

Comment thread src/Servers/Kestrel/Core/src/Internal/Http3/Http3Stream.cs Outdated
Comment thread src/Servers/Kestrel/Core/src/Internal/Http3/Http3Stream.cs
Comment thread src/Servers/Kestrel/Core/src/Internal/Http3/Http3Stream.cs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@cincuranet
cincuranet marked this pull request as ready for review July 31, 2026 09:01
@cincuranet
cincuranet marked this pull request as draft July 31, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix h3 connection-level and stream-level abort locking

2 participants