-
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
SSLHandler can fail if writes occur before channelActive
fired
#8479
Comments
@tbrooks8 thanks... I will try to find some time to fix this or if you are interested in providing a PR I am happy to review as well :) |
I might have time tomorrow to put together a PR. I'll let you know. |
@tbrooks8 don't worry I am able to reproduce with a unit test... Seems to only happen on Java11 tho :) Should have a fix soon. |
normanmaurer
added a commit
that referenced
this issue
Nov 9, 2018
…ive fired Motivation: If you attempt to write to a channel with an SslHandler prior to channelActive being called you can hit an assertion. In particular - if you write to a channel it forces some handshaking (through flush calls) to occur. The AssertionError only happens on Java11+. Modifications: - Replace assert by an "early return" in case of the handshake be done already. - Add unit test that verifies we do not hit the AssertionError anymore and that the future is correctly failed. Result: Fixes #8479.
Should be fixed by #8486 |
normanmaurer
added a commit
that referenced
this issue
Nov 11, 2018
#8486) Motivation: If you attempt to write to a channel with an SslHandler prior to channelActive being called you can hit an assertion. In particular - if you write to a channel it forces some handshaking (through flush calls) to occur. The AssertionError only happens on Java11+. Modifications: - Replace assert by an "early return" in case of the handshake be done already. - Add unit test that verifies we do not hit the AssertionError anymore and that the future is correctly failed. Result: Fixes #8479.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
Attempting to write to a channel with an SslHandler when the
channel.writeable.isWritable()
returns true should be allowed.Actual behavior
If you attempt to write to a channel with an
SslHandler
prior tochannelActive
being called you can hit an assertion. In particular - if you write to a channel it forces some handshaking (through flush calls) to occur. If the handshake fails - the promise is set to failed. This happens around line1573
in theSslHandler.java
.I can tell that
channelActive
has not been called because I am in the debugger and thehandshakeStarted
field returns false. However,ctx.channel().isWriteable()
returns true. So I do not think I am doing anything incorrect.Eventually netty gets around to calling
channelActive
. This call makes its way down to:via:
There is an assertion at line 1747 that triggers because the handshake status is set to HandshakeStatus.NOT_HANDSHAKING and the handshake promise is done:
Steps to reproduce
I reliably reproduce this by attaching a listener to the netty connect future that initiates an application level write. When the connection is complete we start a write the does enough to cause the handshake to fail before the
channelActive
is called. The reason the handshake is failing is a specific scenario we are testing:Which explains why the handshake is failing so fast.
The stacktrace for the connection callback -> write process is:
Netty version
Netty 4.1.30-Final
JVM version (e.g.
java -version
)openjdk version "11" 2018-09-25
OS version (e.g.
uname -a
)Darwin 18.2.0 Darwin Kernel Version 18.2.0
The text was updated successfully, but these errors were encountered: