Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash fix: Multiple bad messages could trigger reentrancy issue #379

Merged
merged 2 commits into from
Aug 3, 2023

Conversation

fabianfett
Copy link
Collaborator

@fabianfett fabianfett commented Aug 3, 2023

If we receive multiple unexpected messages from the backend we can run into a reentrency situation in which we still have unread messages in the incomming buffer after we have received channelInactive. This pr patches this crash.

Fixes the crash mentioned in #374.

If we receive multiple unexpected messages from the backend we can run into a reentrency situation in which we still have unread messages in the incomming buffer after we have received `channelInactive`. This pr patches this crash.
@fabianfett fabianfett added the semver-patch No public API change. label Aug 3, 2023
Copy link
Member

@gwynne gwynne left a comment

Choose a reason for hiding this comment

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

LGTM aside from one comment nit

// We might run into this case because of reentrancy. For example: After we received an
// backend unexpected message, that we read of the wire, we bring this connection into
// the error state and will try to close the connection. The call to close() might be
// executed sync. This means that we received a `channelInactive` before we
Copy link
Member

Choose a reason for hiding this comment

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

before we what...?

@codecov-commenter
Copy link

codecov-commenter commented Aug 3, 2023

Codecov Report

Merging #379 (39c5d72) into main (f3587a5) will increase coverage by 0.09%.
The diff coverage is 67.16%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #379      +/-   ##
==========================================
+ Coverage   44.35%   44.44%   +0.09%     
==========================================
  Files         118      118              
  Lines        8630     8639       +9     
==========================================
+ Hits         3828     3840      +12     
+ Misses       4802     4799       -3     
Files Changed Coverage Δ
...nection State Machine/ConnectionStateMachine.swift 56.33% <66.66%> (+0.65%) ⬆️
...urces/PostgresNIO/New/PostgresChannelHandler.swift 61.05% <67.27%> (+0.07%) ⬆️

@fabianfett fabianfett merged commit 718d154 into vapor:main Aug 3, 2023
10 checks passed
@fabianfett fabianfett deleted the ff-fix-reentrant-failures branch August 3, 2023 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants