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

SSLHandler handleRemoved called before handlerAdded #6536

Closed
yogeshvedpathak opened this issue Mar 13, 2017 · 7 comments
Closed

SSLHandler handleRemoved called before handlerAdded #6536

yogeshvedpathak opened this issue Mar 13, 2017 · 7 comments
Assignees
Labels
Milestone

Comments

@yogeshvedpathak
Copy link

I am getting following stack trace when a connection terminates. I think the null pointer exception is originated because pendingUnencryptedWrites is null at link 415. This could happen when handleRemoved is called before the handleAdded

2017-03-10 00:04:12.063 WARN [nioEventLoopGroup-3-5] io.netty.channel.DefaultChannelPipeline - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
io.netty.channel.ChannelPipelineException: io.netty.handler.ssl.SslHandler.handlerRemoved() has thrown an exception.
at io.netty.channel.DefaultChannelPipeline.callHandlerRemoved0(DefaultChannelPipeline.java:621) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.channel.DefaultChannelPipeline.destroyDown(DefaultChannelPipeline.java:868) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.channel.DefaultChannelPipeline.destroyUp(DefaultChannelPipeline.java:834) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.channel.DefaultChannelPipeline.destroy(DefaultChannelPipeline.java:826) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.channel.DefaultChannelPipeline.access$700(DefaultChannelPipeline.java:43) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelUnregistered(DefaultChannelPipeline.java:1276) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelUnregistered(AbstractChannelHandlerContext.java:185) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelUnregistered(AbstractChannelHandlerContext.java:171) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelUnregistered(DefaultChannelPipeline.java:811) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:699) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:408) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:441) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144) [netty-all-4.0.41.Final.jar:4.0.41.Final]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_45-internal]
Caused by: java.lang.NullPointerException

@johnou
Copy link
Contributor

johnou commented Mar 13, 2017

@yogeshvedpathak would be nice if you could provide more information, reproducer would be a huge help.

@normanmaurer
Copy link
Member

Is there no stack for the NPE?

@yogeshvedpathak
Copy link
Author

Unfortunately there is no stack trace for NPE (i was surprised by that that.) From the other logs from our application i can tell that thi happens right after connection termination. So my best guess is that NPE is coming from pendingUnencryptedWrites being null.

@normanmaurer
Copy link
Member

normanmaurer commented Mar 13, 2017 via email

@johnou
Copy link
Contributor

johnou commented Mar 13, 2017

@yogeshvedpathak you might also consider adding -XX:-OmitStackTraceInFastThrow to your JVM args.

@normanmaurer
Copy link
Member

As noted please upgrade to latest version and re-open if you still see the issue with more details

normanmaurer added a commit that referenced this issue Dec 22, 2018
…adding the handler to the pipeline.

Motivation:

Due a race in DefaultChannelPipeline / AbstractChannelHandlerContext it was possible to have only handlerRemoved(...) called during tearing down the pipeline, even when handlerAdded(...) was never called. We need to ensure we either call both of none to guarantee a proper lifecycle of the handler.

Modifications:

- Enforce handlerAdded(...) / handlerRemoved(...) semantics / ordering
- Add unit test.

Result:

Fixes #8676 / #6536 .
@normanmaurer normanmaurer added this to the 4.1.33.Final milestone Dec 22, 2018
@normanmaurer
Copy link
Member

@yogeshvedpathak #8684 PTAL

@normanmaurer normanmaurer self-assigned this Dec 27, 2018
normanmaurer added a commit that referenced this issue Jan 14, 2019
…adding the handler to the pipeline. (#8684)

Motivation:

Due a race in DefaultChannelPipeline / AbstractChannelHandlerContext it was possible to have only handlerRemoved(...) called during tearing down the pipeline, even when handlerAdded(...) was never called. We need to ensure we either call both of none to guarantee a proper lifecycle of the handler.

Modifications:

- Enforce handlerAdded(...) / handlerRemoved(...) semantics / ordering
- Add unit test.

Result:

Fixes #8676 / #6536 .
normanmaurer added a commit that referenced this issue Jan 14, 2019
…adding the handler to the pipeline. (#8684)

Motivation:

Due a race in DefaultChannelPipeline / AbstractChannelHandlerContext it was possible to have only handlerRemoved(...) called during tearing down the pipeline, even when handlerAdded(...) was never called. We need to ensure we either call both of none to guarantee a proper lifecycle of the handler.

Modifications:

- Enforce handlerAdded(...) / handlerRemoved(...) semantics / ordering
- Add unit test.

Result:

Fixes #8676 / #6536 .
cuteant added a commit to cuteant/SpanNetty that referenced this issue Jan 17, 2019
…adding the handler to the pipeline.

Motivation:

Due a race in DefaultChannelPipeline / AbstractChannelHandlerContext it was possible to have only handlerRemoved(...) called during tearing down the pipeline, even when handlerAdded(...) was never called. We need to ensure we either call both of none to guarantee a proper lifecycle of the handler.

Modifications:

- Enforce handlerAdded(...) / handlerRemoved(...) semantics / ordering
- Add unit test.

Result:

Fixes netty/netty#8676 / netty/netty#6536 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants