Skip to content

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 <[email protected]>
@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 added 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 <[email protected]>
(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 <[email protected]>
(cherry picked from commit fdc3a31)

Co-authored-by: Rick Newton-Rogers <[email protected]>
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