Skip to content

Netty: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1 during File Upload #33106

@volosied

Description

@volosied

Describe the bug
Upload a file via Netty when the file size is greater predefined limit (set via <httpOptions MessageSizeLimit="XXX"/>)

Steps to Reproduce

  1. Use Netty and HTTP 1.1
  2. Set a Max Size Limit via MessageSizeLimit
  3. Upload a larger file.

An error should occur (caused by exceeding the file size) , but not this.

[10/10/25, 12:47:18:443 EDT] 0000005c LoggingRecvBy 1   read (async) requested for local: /127.0.0.1:9080 remote: /127.0.0.1:61918
[10/10/25, 12:47:18:443 EDT] 0000005c TCPLoggingHan 1   read (async) called for local: /127.0.0.1:9080 remote: /127.0.0.1:61918 bytes read: 32768
[10/10/25, 12:47:18:443 EDT] 0000005c TCPLoggingHan 1   read completed. Read: 32768 bytes
[10/10/25, 12:47:18:443 EDT] 0000005c LoggingRecvBy 1   read (async) requested for local: /127.0.0.1:9080 remote: /127.0.0.1:61918
[10/10/25, 12:47:18:443 EDT] 0000005c TCPLoggingHan 1   read (async) called for local: /127.0.0.1:9080 remote: /127.0.0.1:61918 bytes read: 6304
[10/10/25, 12:47:18:443 EDT] 0000005c HttpDispatche >  exceptionCaught Entry  
                                 ChannelHandlerContext(HTTP_DISPATCHER, [id: 0xee5b7669, L:/127.0.0.1:9080 - R:/127.0.0.1:61918])
                                 io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
	at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:83)
	at io.netty.util.internal.ReferenceCountUpdater.release(ReferenceCountUpdater.java:148)
	at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:101)
	at io.netty.handler.codec.http.DefaultHttpContent.release(DefaultHttpContent.java:92)
	at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:90)
	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:106)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
	at io.netty.handler.codec.http.HttpServerKeepAliveHandler.channelRead(HttpServerKeepAliveHandler.java:64)
	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.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:107)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
	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.openliberty.netty.internal.tcp.TCPLoggingHandler.channelRead(TCPLoggingHandler.java:110)
	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:1357)
	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:868)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:796)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:732)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:658)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:998)
	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)

[10/10/25, 12:47:18:444 EDT] 0000005c TCPUtils      >  logChannelStopped Entry  
                                 [id: 0xee5b7669, L:/127.0.0.1:9080 ! R:/127.0.0.1:61918]
[10/10/25, 12:47:18:444 EDT] 0000005c TCPUtils      3   Socket channel closed, local: /127.0.0.1:9080 remote: /127.0.0.1:61918
[10/10/25, 12:47:18:444 EDT] 0000005c TCPUtils      <  logChannelStopped Exit 
[10/10/25, 12:47:18:444 EDT] 0000005c HttpDispatche <  exceptionCaught Exit 
[10/10/25, 12:47:18:444 EDT] 0000005c TCPLoggingHan 1   read completed. Read: 6304 bytes
[10/10/25, 12:47:18:444 EDT] 0000005c TCPLoggingHan 1   SocketChannel closed, local: /127.0.0.1:9080 remote: /127.0.0.1:61918
[10/10/25, 12:47:18:444 EDT] 0000005c TimeoutHandle >  handlerRemoved Entry  
                                 ChannelHandlerContext(timeoutHandler, [id: 0xee5b7669, L:/127.0.0.1:9080 ! R:/127.0.0.1:61918])

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Completed Tasks

Relationships

None yet

Development

No branches or pull requests

Issue actions