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

channelRead invoked before channelActive #196

Open
vlm opened this issue Mar 20, 2018 · 4 comments
Open

channelRead invoked before channelActive #196

vlm opened this issue Mar 20, 2018 · 4 comments
Labels
kind/bug Feature doesn't work as expected.

Comments

@vlm
Copy link
Contributor

vlm commented Mar 20, 2018

Expected behavior

The Channel callbacks lifecycle should start with channelActive and end with channelInactive.

Actual behavior

Sometimes under high concurrency the channelRead is invoked prior to channelActive.

Steps to reproduce

Run the attached code.

The code fails in one of three ways:

  1. It either gets stuck
  2. Or it fails with Illegal Instruction on a DispatchQueue (entering some q.sync)
  3. Or it fails with
Precondition failed: channelRead before channelActive!: file StuckTest/RemoteSystem.swift, line 224
Illegal instruction: 4

The first two failures might not be relevant, but it warrants to take a look. This particular issue is mainly about failure number 3, Precondition failed.

Minimal yet complete reproducer code

StuckTest.zip

SwiftNIO version/commit hash

681ddd8bab4fac997cbc70ca15a1e13c74da50b9 (nmaurer/order_fix)

Swift & OS version (output of swift --version && uname -a)

Apple Swift version 4.1 (swiftlang-902.0.38 clang-902.0.30)
Target: x86_64-apple-darwin17.4.0
Darwin Levs-MacBook-Pro.local 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64

@vlm
Copy link
Contributor Author

vlm commented Mar 20, 2018

FYI: #195 did not help.

@normanmaurer
Copy link
Member

normanmaurer commented Mar 20, 2018 via email

@weissi weissi added the kind/bug Feature doesn't work as expected. label Mar 20, 2018
@vlm
Copy link
Contributor Author

vlm commented Mar 21, 2018

FYI: #204 did not help either. It just made it pop up a bit less frequently.

weissi pushed a commit to weissi/swift-nio that referenced this issue Jun 13, 2020
weissi pushed a commit to weissi/swift-nio that referenced this issue Feb 3, 2024
* Fix documentation and add support for CI-ing it

* Soundness cleanup
@weissi weissi reopened this Jul 9, 2024
@weissi
Copy link
Member

weissi commented Jul 9, 2024

This could still be happening. Probably related to #2773 . The recipe for bad stuff would be to trigger operations from the connect promise. Then they come in after the channel is fully active, but before we call channelActive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Feature doesn't work as expected.
Projects
None yet
Development

No branches or pull requests

3 participants