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

BaseSocketChannel flushNow IONotificationState changes #2954

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

rnro
Copy link
Contributor

@rnro rnro commented Oct 29, 2024

Motivation:

We could previously hit an assert do to a re-entrancy issue where channel and buffered write state could change during a call-out leading to invalid state.

Modifications:

The decision on whether or not we should be registered for future writes is now taken after the call outs to fireChannelWritabilityChanged and fireChannelReadComplete. The new registration state is set to .unregister if the channel is not open or if there are now flushed pending writes.

Result:

Scope for re-entrancy crashes is reduced.

@rnro rnro added the 🔨 semver/patch No public API change. label Oct 29, 2024
Motivation:

We could previously hit an assert do to a re-entrancy issue where
channel and buffered write state could change during a call-out leading
to invalid state.

Modifications:

The decision on whether or not we should be registered for future writes
is now taken after the call outs to `fireChannelWritabilityChanged` and
`fireChannelReadComplete`. The new registration state is set to
`.unregister` if the channel is not open or if there are now flushed
pending writes.

Result:

Scope for re-entrancy crashes is reduced.

Co-authored-by: Cory Benfield <lukasa@apple.com>
@rnro rnro force-pushed the base_socket_crash branch from 7bb69ad to c895291 Compare October 29, 2024 14:58
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Nice one, thanks @rnro!

@Lukasa Lukasa merged commit fdc3a31 into apple:main Oct 30, 2024
41 of 43 checks passed
@rnro rnro deleted the base_socket_crash branch October 31, 2024 09:27
Lukasa pushed a commit to Lukasa/swift-nio that referenced this pull request Nov 21, 2024
### Motivation:

We could previously hit an assert do to a re-entrancy issue where
channel and buffered write state could change during a call-out leading
to invalid state.

### Modifications:

The decision on whether or not we should be registered for future writes
is now taken after the call outs to `fireChannelWritabilityChanged` and
`fireChannelReadComplete`. The new registration state is set to
`.unregister` if the channel is not open or if there are now flushed
pending writes.

### Result:

Scope for re-entrancy crashes is reduced.

Co-authored-by: Cory Benfield <lukasa@apple.com>
(cherry picked from commit fdc3a31)
Lukasa added a commit that referenced this pull request Nov 21, 2024
…) (#2981)

### Motivation:

We could previously hit an assert do to a re-entrancy issue where
channel and buffered write state could change during a call-out leading
to invalid state.

### Modifications:

The decision on whether or not we should be registered for future writes
is now taken after the call outs to `fireChannelWritabilityChanged` and
`fireChannelReadComplete`. The new registration state is set to
`.unregister` if the channel is not open or if there are now flushed
pending writes.

### Result:

Scope for re-entrancy crashes is reduced.

Co-authored-by: Cory Benfield <lukasa@apple.com>
(cherry picked from commit fdc3a31)

Co-authored-by: Rick Newton-Rogers <rnro@apple.com>
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.

2 participants