Skip to content

Fix possible NPE when trying to generate source ids for remote peer t… #631

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

Merged
merged 4 commits into from
Dec 1, 2023

Conversation

normanmaurer
Copy link
Member

…o use.

Motivation:

We need to ensure we check if we already have some source id before trying to use the source id to generate more ids for the remote peer to use otherwhise we might see a NPE:

11:58:38.663 [nioEventLoopGroup-2-1] DEBUG io.netty.incubator.codec.quic.QuicheQuicCodec -- Error while processing QUIC packet
java.lang.NullPointerException: Cannot read field "connId" because "this.localIdAdrr" is null
	at io.netty.incubator.codec.quic.QuicheQuicChannel.newSourceConnectionIds(QuicheQuicChannel.java:917)
	at io.netty.incubator.codec.quic.QuicheQuicServerCodec.channelRecv(QuicheQuicServerCodec.java:110)
	at io.netty.incubator.codec.quic.QuicheQuicCodec$QuicCodecHeaderProcessor.process(QuicheQuicCodec.java:293)
	at io.netty.incubator.codec.quic.QuicHeaderParser.parse(QuicHeaderParser.java:127)
	at io.netty.incubator.codec.quic.QuicheQuicCodec.handleQuicPacket(QuicheQuicCodec.java:164)
	at io.netty.incubator.codec.quic.QuicheQuicCodec.channelRead(QuicheQuicCodec.java:155)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:97)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Modifications:

Always retrieve the source id and check for null without caching it. This is also needed as the source id might change during the life-time of the connection

Result:

No more NPE

…o use.

Motivation:

We need to ensure we check if we already have some source id before trying to use the source id to generate more ids for the remote peer to use otherwhise we might see a NPE:

```
11:58:38.663 [nioEventLoopGroup-2-1] DEBUG io.netty.incubator.codec.quic.QuicheQuicCodec -- Error while processing QUIC packet
java.lang.NullPointerException: Cannot read field "connId" because "this.localIdAdrr" is null
	at io.netty.incubator.codec.quic.QuicheQuicChannel.newSourceConnectionIds(QuicheQuicChannel.java:917)
	at io.netty.incubator.codec.quic.QuicheQuicServerCodec.channelRecv(QuicheQuicServerCodec.java:110)
	at io.netty.incubator.codec.quic.QuicheQuicCodec$QuicCodecHeaderProcessor.process(QuicheQuicCodec.java:293)
	at io.netty.incubator.codec.quic.QuicHeaderParser.parse(QuicHeaderParser.java:127)
	at io.netty.incubator.codec.quic.QuicheQuicCodec.handleQuicPacket(QuicheQuicCodec.java:164)
	at io.netty.incubator.codec.quic.QuicheQuicCodec.channelRead(QuicheQuicCodec.java:155)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:97)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:1583)
```

Modifications:

Always retrieve the source id and check for null without caching it. This is also needed as the source id might change during the life-time of the connection

Result:

No more NPE
@normanmaurer normanmaurer added this to the 0.0.54.Final milestone Dec 1, 2023
@normanmaurer normanmaurer merged commit c85d975 into main Dec 1, 2023
@normanmaurer normanmaurer deleted the id_fix branch December 1, 2023 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant