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

HttpPostStandardRequestDecoder memory leak #9513

Closed
rhythmdai opened this issue Aug 26, 2019 · 0 comments · Fixed by #9517
Closed

HttpPostStandardRequestDecoder memory leak #9513

rhythmdai opened this issue Aug 26, 2019 · 0 comments · Fixed by #9517
Milestone

Comments

@rhythmdai
Copy link

String payload = "a=1&&b=2";
ByteBuf byteBuf = Unpooled.directBuffer().writeBytes(payload.getBytes());
FullHttpRequest request =new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/",byteBuf);
HttpPostStandardRequestDecoder decoder = new HttpPostStandardRequestDecoder(request);

Expected behavior

throw ErrorDataDecoderException and free direct memory allocated in constructor

Created at:
io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:331)
io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:185)
io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:176)
io.netty.buffer.CompositeByteBuf.allocBuffer(CompositeByteBuf.java:1661)
io.netty.buffer.CompositeByteBuf.copy(CompositeByteBuf.java:1340)
io.netty.buffer.AbstractByteBuf.copy(AbstractByteBuf.java:1190)
io.netty.buffer.WrappedCompositeByteBuf.copy(WrappedCompositeByteBuf.java:488)
io.netty.buffer.AdvancedLeakAwareCompositeByteBuf.copy(AdvancedLeakAwareCompositeByteBuf.java:681)
io.netty.handler.codec.http.multipart.HttpPostStandardRequestDecoder.offer(HttpPostStandardRequestDecoder.java:282)
io.netty.handler.codec.http.multipart.HttpPostStandardRequestDecoder.(HttpPostStandardRequestDecoder.java:154)
io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.(HttpPostRequestDecoder.java:99)
io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.(HttpPostRequestDecoder.java:52)

Actual behavior

thow Exception , but direct memory is not freed.

Steps to reproduce

allocate direct memory in constructor , when exception appear , memory is not freed

Minimal yet complete reproducer code (or URL to code)

Netty version

Netty version: 4.1.30.Final

JVM version (e.g. java -version)

jdk8

OS version (e.g. uname -a)

win10 and Linux 4.9.0-39-custom #12 SMP Sat Jul 22 13:14:22 CST 2017 x86_64 x86_64 x86_64 GNU/Linux``

@normanmaurer normanmaurer added this to the 4.1.40.Final milestone Aug 27, 2019
normanmaurer added a commit that referenced this issue Aug 27, 2019
…rrorDataDecoderException.

Motivation:

Currently when HttpPostStandardRequestDecoder throws a ErrorDataDecoderException during construction we leak memory. We need to ensure all is released correctly.

Modifications:

- Call destroy() if parseBody() throws and rethrow the ErrorDataDecoderException
- Add unit test

Result:

Fixes #9513.
normanmaurer added a commit that referenced this issue Aug 28, 2019
…rrorDataDecoderException. (#9517)

Motivation:

Currently when HttpPostStandardRequestDecoder throws a ErrorDataDecoderException during construction we leak memory. We need to ensure all is released correctly.

Modifications:

- Call destroy() if parseBody() throws and rethrow the ErrorDataDecoderException
- Add unit test

Result:

Fixes #9513.
normanmaurer added a commit that referenced this issue Aug 28, 2019
…rrorDataDecoderException. (#9517)

Motivation:

Currently when HttpPostStandardRequestDecoder throws a ErrorDataDecoderException during construction we leak memory. We need to ensure all is released correctly.

Modifications:

- Call destroy() if parseBody() throws and rethrow the ErrorDataDecoderException
- Add unit test

Result:

Fixes #9513.
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 a pull request may close this issue.

2 participants