don't unlock the receive stream mutex for copying from STREAM frames #3290
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.
Fixes #3257. @arashpayan can you review this PR please? I'm planning to cut a new quic-go release early next week, and would love to get this fix in.
The problem here was the mutex in the
receiveStream
:https://github.com/lucas-clemente/quic-go/blob/a22a9eae30618491bf6c40ad20918650e2a2ab7b/receive_stream.go#L169-L175
We unlocked this mutex when copying data from the STREAM frame to the
b
slice of theRead
call. If during this timeCancelRead
is called:https://github.com/lucas-clemente/quic-go/blob/a22a9eae30618491bf6c40ad20918650e2a2ab7b/receive_stream.go#L200-L209
This would call
onStreamCompleted
for the first time.onStreamCompleted
removes the stream from the streams map.If the STREAM frame copied in the
Read
call was the last STREAM frame of the stream (i.e. the one carrying the FIN bit), we'd callonStreamCompleted
again, trying to delete the previously deleted stream, leading to an INTERNAL_ERROR.This PR also adds an integration test which is capable of reproducing the bug reliable within just a few repetitions.