question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CorruptedFrameException in LengthFieldBasedFrameDecoder when using Epoll with AdaptiveRecvByteBufAllocator

See original GitHub issue

Been using this code for years:

    new LengthFieldBasedFrameDecoder(1400, 0, 2, -2, 0, true),

It worked with NIO for a long time, and with EPOLL for several Netty versions. But now it fails with the exception seen below.

Expected behavior

Frames are read correctly.

Actual behavior

Exception is thrown when using EPOLL mode:

    io.netty.handler.codec.CorruptedFrameException: Adjusted frame length (0) is less than lengthFieldEndOffset: 2
    	at io.netty.handler.codec.LengthFieldBasedFrameDecoder.failOnFrameLengthLessThanLengthFieldEndOffset(LengthFieldBasedFrameDecoder.java:360)
    	at io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:417)
    	at io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:334)
    	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:503)
    	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:442)
    	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:281)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:287)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931)
    	at io.netty.channel.epoll.EpollDatagramChannel.read(EpollDatagramChannel.java:688)
    	at io.netty.channel.epoll.EpollDatagramChannel.access$100(EpollDatagramChannel.java:57)
    	at io.netty.channel.epoll.EpollDatagramChannel$EpollDatagramChannelUnsafe.epollInReady(EpollDatagramChannel.java:507)
    	at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe$1.run(AbstractEpollChannel.java:394)
    	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
    	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:510)
    	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:413)
    	at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050)
    	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    	at java.base/java.lang.Thread.run(Thread.java:834)

Steps to reproduce

Unable to provide access to private data stream.

Netty version

4.1.43.Final

JVM version (e.g. java -version)

openjdk version “11.0.5” 2019-10-15 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)

OS version (e.g. uname -a)

Linux 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:66 (25 by maintainers)

github_iconTop GitHub Comments

1reaction
morvaelcommented, Nov 27, 2019

Ok, but that will have to wait for tomorrow.

0reactions
morvaelcommented, Nov 29, 2019

Turns out to be too complicated. #512 was fixed, but not in the release used by netty 44 snapshot. Also, when compiled under ppc64le, I get a netty-all version that I can’t test on my x86_64 machine (for that I would use your x86_64 so), because there is no epoll .so for me. I don’t want to setup another compilation environment on my machine, so I guess I’ll have to wait for 44 release 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

LengthFieldBasedFrameDecoder (Netty API Reference (4.1 ...
A decoder that splits the received ByteBuf s dynamically by the value of the length field in the message. It is particularly useful...
Read more >
EpollDomainSocketEchoTest.java example - Javatips.net
This class describes the usage of EpollDomainSocketEchoTest.java.
Read more >
Index (Netty API Reference (4.0.54.Final)) - javadoc.io
Use AbstractEpollServerChannel. ... AdaptiveRecvByteBufAllocator - Class in io.netty.channel ... CorruptedFrameException() - Constructor for exception ...
Read more >
https://www.vmware.com/content/dam/aw-microsites/o...
The VMware Product that includes this file does not necessarily use all the open source software ... io/netty/channel/epoll/EpollDatagramChannelConfig.java ...
Read more >
io.netty.handler.codec.base64 (Netty API Reference (4.1.11.Final))
Package io.netty.handler.codec.base64 Description · Overview · Package · Class · Use · Tree · Deprecated · Index · Help.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found