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

NullPointerException while processing http2 Priority Frame #10941

Closed
atropnikov opened this issue Jan 15, 2021 · 6 comments · Fixed by #10943
Closed

NullPointerException while processing http2 Priority Frame #10941

atropnikov opened this issue Jan 15, 2021 · 6 comments · Fixed by #10943

Comments

@atropnikov
Copy link

Expected behavior

No NPE

Actual behavior

java.lang.NullPointerException: null at io.netty.handler.codec.http2.Http2FrameCodec$FrameListener.requireStream(Http2FrameCodec.java:679) at io.netty.handler.codec.http2.Http2FrameCodec$FrameListener.onPriorityRead(Http2FrameCodec.java:661) at io.netty.handler.codec.http2.Http2FrameListenerDecorator.onPriorityRead(Http2FrameListenerDecorator.java:54) at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onPriorityRead(DefaultHttp2ConnectionDecoder.java:386) at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$PrefaceFrameListener.onPriorityRead(DefaultHttp2ConnectionDecoder.java:676) at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readPriorityFrame(DefaultHttp2FrameReader.java:510) at io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:257) at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:160) at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:174) at io.netty.handler.codec.http2.DecoratingHttp2ConnectionDecoder.decodeFrame(DecoratingHttp2ConnectionDecoder.java:63) at io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:378) at io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.decode(Http2ConnectionHandler.java:242) at io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:438) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:508) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:447) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1533) at io.netty.handler.ssl.SslHandler.decodeNonJdkCompatible(SslHandler.java:1294) at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1331) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:508) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:447) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480) at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:832)

Steps to reproduce

Not available now, happens after upgrading to netty 4.1.58 (I suppose it would happen with 4.1.57). I will try to log incoming frames.

Minimal yet complete reproducer code (or URL to code)

Netty version

4.1.58.Final

JVM version (e.g. java -version)

openjdk 14.0.1

OS version (e.g. uname -a)

N/A

@normanmaurer
Copy link
Member

@atropnikov would be interesting to know what streamId this is... Can you provide the info ?

normanmaurer added a commit that referenced this issue Jan 15, 2021
Motivation:

#10765 added support for push promise and priority frames when using the Http2FrameCodec. Unfortunally it didnt correctly guard against the possibility to receive a priority frame for an non-existing stream, which resulted in a NPE

Modifications:

- Ignore priority frame for non existing stream
- Correctly implement equals / hashcode for DefaultHttp2PriorityFrame
- Add unit tests

Result:

Fixes #10941
@normanmaurer
Copy link
Member

I think this should be fixed by #10943

@atropnikov
Copy link
Author

20:13:56.716 [epollEventLoopGroup-13-5] INFO http2.Http2FrameLogger: [id: 0x9c52a9f6, L:/176.112.196.170:443 - R:/95.161.182.242:61412] OUTBOUND SETTINGS: ack=false settings={=524280, =16384}
20:13:56.717 [epollEventLoopGroup-13-5] INFO http2.Http2FrameLogger: [id: 0x9c52a9f6, L:/176.112.196.170:443 - R:/95.161.182.242:61412] OUTBOUND WINDOW_UPDATE: streamId=0 windowSizeIncrement=917490
20:13:56.718 [epollEventLoopGroup-13-5] INFO http2.Http2FrameLogger: [id: 0x9c52a9f6, L:/176.112.196.170:443 - R:/95.161.182.242:61412] INBOUND SETTINGS: ack=false settings={=65536, =131072, =16384}
20:13:56.718 [epollEventLoopGroup-13-5] INFO http2.Http2FrameLogger: [id: 0x9c52a9f6, L:/176.112.196.170:443 - R:/95.161.182.242:61412] OUTBOUND SETTINGS: ack=true
20:13:56.718 [epollEventLoopGroup-13-5] INFO http2.Http2FrameLogger: [id: 0x9c52a9f6, L:/176.112.196.170:443 - R:/95.161.182.242:61412] INBOUND WINDOW_UPDATE: streamId=0 windowSizeIncrement=12517377
20:13:56.718 [epollEventLoopGroup-13-5] INFO http2.Http2FrameLogger: [id: 0x9c52a9f6, L:/176.112.196.170:443 - R:/95.161.182.242:61412] INBOUND PRIORITY: streamId=3 streamDependency=0 weight=201 exclusive=false
20:13:56.730 [epollEventLoopGroup-13-6] ERROR handler.Http2MultiplexExceptionHandler: Pipeline Exception
java.lang.NullPointerException: null
	at io.netty.handler.codec.http2.Http2FrameCodec$FrameListener.requireStream(Http2FrameCodec.java:679) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.Http2FrameCodec$FrameListener.onPriorityRead(Http2FrameCodec.java:661) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.Http2FrameListenerDecorator.onPriorityRead(Http2FrameListenerDecorator.java:54) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onPriorityRead(DefaultHttp2ConnectionDecoder.java:386) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$PrefaceFrameListener.onPriorityRead(DefaultHttp2ConnectionDecoder.java:676) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.Http2InboundFrameLogger$1.onPriorityRead(Http2InboundFrameLogger.java:73) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readPriorityFrame(DefaultHttp2FrameReader.java:510) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:257) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:160) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.Http2InboundFrameLogger.readFrame(Http2InboundFrameLogger.java:41) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:174) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.DecoratingHttp2ConnectionDecoder.decodeFrame(DecoratingHttp2ConnectionDecoder.java:63) ~[vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:378) [vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.decode(Http2ConnectionHandler.java:242) [vpnendpoint.jar:?]
	at io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:438) [vpnendpoint.jar:?]
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:508) [vpnendpoint.jar:?]
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:447) [vpnendpoint.jar:?]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) [vpnendpoint.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [vpnendpoint.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [vpnendpoint.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [vpnendpoint.jar:?]
	at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1533) [vpnendpoint.jar:?]
	at io.netty.handler.ssl.SslHandler.decodeNonJdkCompatible(SslHandler.java:1294) [vpnendpoint.jar:?]
	at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1331) [vpnendpoint.jar:?]
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:508) [vpnendpoint.jar:?]
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:447) [vpnendpoint.jar:?]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) [vpnendpoint.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [vpnendpoint.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [vpnendpoint.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [vpnendpoint.jar:?]
	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) [vpnendpoint.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [vpnendpoint.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [vpnendpoint.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [vpnendpoint.jar:?]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [vpnendpoint.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [vpnendpoint.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [vpnendpoint.jar:?]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [vpnendpoint.jar:?]
	at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) [vpnendpoint.jar:?]
	at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480) [vpnendpoint.jar:?]
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) [vpnendpoint.jar:?]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) [vpnendpoint.jar:?]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [vpnendpoint.jar:?]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [vpnendpoint.jar:?]
	at java.lang.Thread.run(Thread.java:832) [?:?]

@normanmaurer
Copy link
Member

@atropnikov thanks ... I suspect this should be fixed by: #10943

Is it possible for you to verify ?

@normanmaurer normanmaurer added this to the 4.1.59.Final milestone Jan 15, 2021
@atropnikov
Copy link
Author

Yes, we will try to verify soon.

@normanmaurer
Copy link
Member

Keep me posted

normanmaurer added a commit that referenced this issue Jan 18, 2021
…10943)


Motivation:

#10765 added support for push promise and priority frames when using the Http2FrameCodec. Unfortunally it didnt correctly guard against the possibility to receive a priority frame for an non-existing stream, which resulted in a NPE

Modifications:

- Ignore priority frame for non existing stream
- Correctly implement equals / hashcode for DefaultHttp2PriorityFrame
- Add unit tests

Result:

Fixes #10941
normanmaurer added a commit that referenced this issue Jan 18, 2021
…10943)

Motivation:

#10765 added support for push promise and priority frames when using the Http2FrameCodec. Unfortunally it didnt correctly guard against the possibility to receive a priority frame for an non-existing stream, which resulted in a NPE

Modifications:

- Ignore priority frame for non existing stream
- Correctly implement equals / hashcode for DefaultHttp2PriorityFrame
- Add unit tests

Result:

Fixes #10941
ZzxyNn pushed a commit to ZzxyNn/netty that referenced this issue Jan 29, 2021
…etty#10943)


Motivation:

netty#10765 added support for push promise and priority frames when using the Http2FrameCodec. Unfortunally it didnt correctly guard against the possibility to receive a priority frame for an non-existing stream, which resulted in a NPE

Modifications:

- Ignore priority frame for non existing stream
- Correctly implement equals / hashcode for DefaultHttp2PriorityFrame
- Add unit tests

Result:

Fixes netty#10941
raidyue pushed a commit to raidyue/netty that referenced this issue Jul 8, 2022
…etty#10943)


Motivation:

netty#10765 added support for push promise and priority frames when using the Http2FrameCodec. Unfortunally it didnt correctly guard against the possibility to receive a priority frame for an non-existing stream, which resulted in a NPE

Modifications:

- Ignore priority frame for non existing stream
- Correctly implement equals / hashcode for DefaultHttp2PriorityFrame
- Add unit tests

Result:

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

Successfully merging a pull request may close this issue.

2 participants