quic: fix two small bugs in HTTP/3 stream internals - #65970
Open
pimterry wants to merge 1 commit into
Open
Conversation
Signed-off-by: Tim Perry <pimterry@gmail.com>
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #65970 +/- ##
=======================================
Coverage 90.17% 90.17%
=======================================
Files 771 771
Lines 265470 265470
Branches 50467 50450 -17
=======================================
+ Hits 239382 239396 +14
- Misses 17033 17044 +11
+ Partials 9055 9030 -25 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes two subtle bugs in HTTP/3 stream handling, originally implemented deep in #63995 as part of restructuring that touched this code. Much easier to review independently here, honestly I hadn't been through that as carefully as I have have with this PR now, breaking this up is definitely worthwhile.
HTTP/3 internal streams creation failure crashes node
When the application starts, it needs to create 3 unidirectional internal streams (1x control + 2x QPACK). It saved
started_ = truebefore creating these streams. If that failed, this remained. When the session then shuts down it checksstarted_and because it's set it tries to tear down those 3 streams, which don't actually exist => 💥We now set
_startedto the actual result of startup.Test here covers that directly, by connecting HTTP/3 with a peer who doesn't allow opening unidirectional streams at all. A remote QUIC peer like this crashes Node today - with this it just kills the session.
HTTP/3 stale stream data reuse
application().GetStreamData(&stream_data)is called in a loop fromSession::SendPendingDatato read the stream data out of the application. It reusesstream_databetween iterations.Previously the QUIC application reset this before using it (here) but the HTTP/3 application did not (here).
This doesn't actually break anything in practice I think, but mostly by luck. Right now, for example,
data->countis set tokMaxVectorCount(16) at the start of the HTTP/3GetStreamDatabut if there's no max data credit left then we just return and do nothing (so we've now updated the data length, but not the content or target stream id - which remain stale from the previous iteration).SendPendingDatathen continues on to callWriteVStreamand thenngtcp2_conn_writev_streamwith this stream data: length=16 plus the stream id & data from the previous iteration. The only reason it doesn't corrupt streams on the wire is that the broken case is only triggered when there's no data credit left, and so ngtcp2 ignores the write. We're currently doing this happy dance every time we hit the credit limit during this loop. AFAICT this means we basically always do an extra write where we unsuccessfully try to send duplicate stale data after we hit the data limit.There's other potential stale data flows here as well, e.g. we bail early if
nghttp3_conn_writev_streamfails.This PR fixes the lot by resetting the stream data consistently in the loop itself instead, extracting that from the QUIC application so it applies to HTTP/3 too.
It also simplifies the related HTTP/3
GetStreamDatalogic: using the fixed value for the count directly instead of writing it to the output struct to pass it across (which seems very odd - looks like this is a complex artifact of historical changes).