GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make public API specify explicit maxAllocation to prevent OOM (#15005) by normanmaurer · Pull Request #15122 · netty/netty

Conversation

@normanmaurer

@normanmaurer normanmaurer commented May 6, 2025

Copy link
Copy Markdown
Member

Motivation:

The current ZLibCodecFactory provides newZlibDecoder methods without an option to specify a maximum memory limit for decompression. These methods are utilized in various parts of the project, such as the per-message WebSocket extension. As a result, a client could send a small, maliciously crafted compressed message that, upon decompression, would consume all available memory. This can lead to an OutOfMemoryError scenario, which can easily be reproduced as follows:

Exception in thread "io-compute-15" java.lang.OutOfMemoryError: Java heap space
	at io.netty.util.internal.PlatformDependent.allocateUninitializedArray(PlatformDependent.java:326)
	at io.netty.buffer.PoolArena$HeapArena.newByteArray(PoolArena.java:628)
	at io.netty.buffer.PoolArena$HeapArena.newUnpooledChunk(PoolArena.java:652)
	at io.netty.buffer.PoolArena.allocateHuge(PoolArena.java:224)
	at io.netty.buffer.PoolArena.allocate(PoolArena.java:142)
	at io.netty.buffer.PoolArena.reallocate(PoolArena.java:317)
	at io.netty.buffer.PooledByteBuf.capacity(PooledByteBuf.java:123)
	at io.netty.buffer.AbstractByteBuf.ensureWritable(AbstractByteBuf.java:333)
	at io.netty.handler.codec.compression.ZlibDecoder.prepareDecompressBuffer(ZlibDecoder.java:74)
	at io.netty.handler.codec.compression.JdkZlibDecoder.decode(JdkZlibDecoder.java:265)
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:530)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:469)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
	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.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.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:348)
	at io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder.decompressContent(DeflateDecoder.java:119)
	at io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder.decode(DeflateDecoder.java:80)
	at io.netty.handler.codec.http.websocketx.extensions.compression.PerMessageDeflateDecoder.decode(PerMessageDeflateDecoder.java:87)
	at io.netty.handler.codec.http.websocketx.extensions.compression.PerMessageDeflateDecoder.decode(PerMessageDeflateDecoder.java:31)
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:91)
	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.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:289)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
java.lang.OutOfMemoryError: Java heap space
	at io.netty.util.internal.PlatformDependent.allocateUninitializedArray(PlatformDependent.java:326)
	at io.netty.buffer.PoolArena$HeapArena.newByteArray(PoolArena.java:628)
	at io.netty.buffer.PoolArena$HeapArena.newUnpooledChunk(PoolArena.java:652)

Modification:

  • Introduced new newZlibDecoder methods within ZlibCodecFactory that include an explicit maxAllocation parameter to specify the maximum allowed memory during decompression.
  • The older methods have been deprecated in favor of the new ones.
  • Public APIs that invoke newZlibDecoder now require the maxAllocation parameter as well.

Result:

This change does not modify the public API behavior, but it encourages users to adopt the updated methods, which include the explicit maxAllocation argument, providing more control over memory usage during decompression.

Fixes #6663.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@DeviLab @normanmaurer
Make public API specify explicit maxAllocation to prevent OOM (#15005)
30e5409
Motivation:

The current `ZLibCodecFactory` provides `newZlibDecoder` methods without
an option to specify a maximum memory limit for decompression. These
methods are utilized in various parts of the project, such as the
per-message WebSocket extension. As a result, a client could send a
small, maliciously crafted compressed message that, upon decompression,
would consume all available memory. This can lead to an
`OutOfMemoryError` scenario, which can easily be reproduced as follows:

```
Exception in thread "io-compute-15" java.lang.OutOfMemoryError: Java heap space
	at io.netty.util.internal.PlatformDependent.allocateUninitializedArray(PlatformDependent.java:326)
	at io.netty.buffer.PoolArena$HeapArena.newByteArray(PoolArena.java:628)
	at io.netty.buffer.PoolArena$HeapArena.newUnpooledChunk(PoolArena.java:652)
	at io.netty.buffer.PoolArena.allocateHuge(PoolArena.java:224)
	at io.netty.buffer.PoolArena.allocate(PoolArena.java:142)
	at io.netty.buffer.PoolArena.reallocate(PoolArena.java:317)
	at io.netty.buffer.PooledByteBuf.capacity(PooledByteBuf.java:123)
	at io.netty.buffer.AbstractByteBuf.ensureWritable(AbstractByteBuf.java:333)
	at io.netty.handler.codec.compression.ZlibDecoder.prepareDecompressBuffer(ZlibDecoder.java:74)
	at io.netty.handler.codec.compression.JdkZlibDecoder.decode(JdkZlibDecoder.java:265)
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:530)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:469)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
	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.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.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:348)
	at io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder.decompressContent(DeflateDecoder.java:119)
	at io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder.decode(DeflateDecoder.java:80)
	at io.netty.handler.codec.http.websocketx.extensions.compression.PerMessageDeflateDecoder.decode(PerMessageDeflateDecoder.java:87)
	at io.netty.handler.codec.http.websocketx.extensions.compression.PerMessageDeflateDecoder.decode(PerMessageDeflateDecoder.java:31)
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:91)
	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.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:289)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
java.lang.OutOfMemoryError: Java heap space
	at io.netty.util.internal.PlatformDependent.allocateUninitializedArray(PlatformDependent.java:326)
	at io.netty.buffer.PoolArena$HeapArena.newByteArray(PoolArena.java:628)
	at io.netty.buffer.PoolArena$HeapArena.newUnpooledChunk(PoolArena.java:652)
```

Modification:

- Introduced new `newZlibDecoder` methods within `ZlibCodecFactory` that
include an explicit `maxAllocation` parameter to specify the maximum
allowed memory during decompression.
- The older methods have been deprecated in favor of the new ones.
- Public APIs that invoke `newZlibDecoder` now require the
`maxAllocation` parameter as well.

Result:

This change does not modify the public API behavior, but it encourages
users to adopt the updated methods, which include the explicit
`maxAllocation` argument, providing more control over memory usage
during decompression.

Fixes #6663.
@normanmaurer normanmaurer added this to the 4.1.122.Final milestone May 6, 2025
@normanmaurer
normanmaurer merged commit a155024 into 4.1 May 6, 2025
@normanmaurer
normanmaurer deleted the max_compress_41 branch May 6, 2025 09:15
violetagg added a commit to reactor/reactor-netty that referenced this pull request Jun 3, 2025
@violetagg
Remove the usage of deprecated functionality
02e660c
Related to
netty/netty#15122

Signed-off-by: Violeta Georgieva <[email protected]>
@violetagg violetagg mentioned this pull request Jun 3, 2025
Remove the usage of deprecated functionality reactor/reactor-netty#3792
Merged
violetagg added a commit to reactor/reactor-netty that referenced this pull request Jun 4, 2025
@violetagg
Remove the usage of deprecated functionality (#3792)
9aef6a1
Related to
netty/netty#15122

Signed-off-by: Violeta Georgieva <[email protected]>
@dongjoon-hyun dongjoon-hyun mentioned this pull request Jun 10, 2025
[SPARK-52438][BUILD] Upgrade Netty to 4.1.122.Final and Netty-tcnative to 2.0.72.Final apache/spark#51145
Closed
LuciferYang pushed a commit to apache/spark that referenced this pull request Jun 11, 2025
@dongjoon-hyun @LuciferYang
[SPARK-52438][BUILD] Upgrade Netty to 4.1.122.Final and Netty-tcnativ…
cadf738
…e to 2.0.72.Final

### What changes were proposed in this pull request?

This PR aims to Upgrade Netty to 4.1.122.Final and Netty-tcnative to 2.0.72.Final.

### Why are the changes needed?

To bring the Java 24 related update and the latest bug fixes.
> We decided to enable sun.misc.Unsafe by default again when using JDK24+ (when possible) as disabling it by default on this java versions did come with quite a performance regression.

- https://netty.io/news/2025/06/03/4-1-122-Final.html
    - netty/netty#15296
    - netty/netty#15248
    - netty/netty#15122

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass the CIs.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #51145 from dongjoon-hyun/SPARK-52438.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: yangjie01 <[email protected]>
violetagg added a commit to reactor/reactor-netty that referenced this pull request Jun 26, 2025
@violetagg
Remove the usage of deprecated functionality
185c917
Related to
netty/netty#15122

Signed-off-by: Violeta Georgieva <[email protected]>
@violetagg violetagg mentioned this pull request Jun 26, 2025
Remove the usage of deprecated functionality reactor/reactor-netty#3819
Merged
violetagg added a commit to reactor/reactor-netty that referenced this pull request Jun 26, 2025
@violetagg
Remove the usage of deprecated functionality (#3819)
d27122c
Related to
netty/netty#15122

Signed-off-by: Violeta Georgieva <[email protected]>
prabhjyotsingh pushed a commit to acceldata-io/spark3 that referenced this pull request Sep 10, 2026
@dongjoon-hyun @prabhjyotsingh
[SPARK-52438][BUILD] Upgrade Netty to 4.1.122.Final and Netty-tcnativ…
f5febd2
…e to 2.0.72.Final

This PR aims to Upgrade Netty to 4.1.122.Final and Netty-tcnative to 2.0.72.Final.

To bring the Java 24 related update and the latest bug fixes.
> We decided to enable sun.misc.Unsafe by default again when using JDK24+ (when possible) as disabling it by default on this java versions did come with quite a performance regression.

- https://netty.io/news/2025/06/03/4-1-122-Final.html
    - netty/netty#15296
    - netty/netty#15248
    - netty/netty#15122

No.

Pass the CIs.

No.

Closes apache#51145 from dongjoon-hyun/SPARK-52438.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: yangjie01 <[email protected]>
prabhjyotsingh pushed a commit to acceldata-io/spark3 that referenced this pull request Sep 11, 2026
@dongjoon-hyun @prabhjyotsingh
[SPARK-52438][BUILD] Upgrade Netty to 4.1.122.Final and Netty-tcnativ…
0920d3a
…e to 2.0.72.Final

This PR aims to Upgrade Netty to 4.1.122.Final and Netty-tcnative to 2.0.72.Final.

To bring the Java 24 related update and the latest bug fixes.
> We decided to enable sun.misc.Unsafe by default again when using JDK24+ (when possible) as disabling it by default on this java versions did come with quite a performance regression.

- https://netty.io/news/2025/06/03/4-1-122-Final.html
    - netty/netty#15296
    - netty/netty#15248
    - netty/netty#15122

No.

Pass the CIs.

No.

Closes apache#51145 from dongjoon-hyun/SPARK-52438.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: yangjie01 <[email protected]>
prabhjyotsingh pushed a commit to acceldata-io/spark3 that referenced this pull request Sep 11, 2026
@dongjoon-hyun @prabhjyotsingh
[SPARK-52438][BUILD] Upgrade Netty to 4.1.122.Final and Netty-tcnativ…
08d9776
…e to 2.0.72.Final

This PR aims to Upgrade Netty to 4.1.122.Final and Netty-tcnative to 2.0.72.Final.

To bring the Java 24 related update and the latest bug fixes.
> We decided to enable sun.misc.Unsafe by default again when using JDK24+ (when possible) as disabling it by default on this java versions did come with quite a performance regression.

- https://netty.io/news/2025/06/03/4-1-122-Final.html
    - netty/netty#15296
    - netty/netty#15248
    - netty/netty#15122

No.

Pass the CIs.

No.

Closes apache#51145 from dongjoon-hyun/SPARK-52438.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: yangjie01 <[email protected]>
Ko-dany pushed a commit to acceldata-io/spark3 that referenced this pull request Sep 11, 2026
@dongjoon-hyun @Ko-dany
[SPARK-52438][BUILD] Upgrade Netty to 4.1.122.Final and Netty-tcnativ…
db26549
…e to 2.0.72.Final

This PR aims to Upgrade Netty to 4.1.122.Final and Netty-tcnative to 2.0.72.Final.

To bring the Java 24 related update and the latest bug fixes.
> We decided to enable sun.misc.Unsafe by default again when using JDK24+ (when possible) as disabling it by default on this java versions did come with quite a performance regression.

- https://netty.io/news/2025/06/03/4-1-122-Final.html
    - netty/netty#15296
    - netty/netty#15248
    - netty/netty#15122

No.

Pass the CIs.

No.

Closes apache#51145 from dongjoon-hyun/SPARK-52438.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: yangjie01 <[email protected]>
This was referenced Sep 14, 2026
Http2: Reserve promised stream for PUSH_PROMISE after local RST_STREAM #17471
Closed
cache failure 1233e4a5 #17565
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.1.122.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@normanmaurer @DeviLab
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.