Skip to content

Fix possible ByteBuf leak when CompositeByteBuf is resized#8946

Merged
normanmaurer merged 1 commit intonetty:4.1from
njhill:cbb-leak-fix
Mar 22, 2019
Merged

Fix possible ByteBuf leak when CompositeByteBuf is resized#8946
normanmaurer merged 1 commit intonetty:4.1from
njhill:cbb-leak-fix

Conversation

@njhill
Copy link
Copy Markdown
Member

@njhill njhill commented Mar 15, 2019

Motivation:

The special case fixed in #8497 also requires that we keep a derived slice when trimming components in place, as done by the capacity(int) and discardReadBytes() methods.

Modifications:

Ensure that we keep a ref to trimmed components' original retained slice in capacity(int) and discardReadBytes() methods, so that it is released properly when the they are later freed. Add unit test which fails prior to the fix.

Result:

Edge case leak is eliminated.

@normanmaurer
Copy link
Copy Markdown
Member

@netty-bot test this please

@netty-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@normanmaurer
Copy link
Copy Markdown
Member

@netty-bot test this please

Motivation:

The special case fixed in netty#8497 also requires that we keep a derived slice when trimming components in place, as done by the capacity(int) and discardReadBytes() methods.

Modifications:

Ensure that we keep a ref to trimmed components' original retained slice in capacity(int) and discardReadBytes() methods, so that it is released properly when the they are later freed. Add unit test which fails prior to the fix.

Result:

Edge case leak is eliminated.
@njhill
Copy link
Copy Markdown
Member Author

njhill commented Mar 15, 2019

FYI I just updated the commit message to fix a typo discardReadComponents -> discardReadBytes.

@normanmaurer
Copy link
Copy Markdown
Member

@netty-bot test this please

2 similar comments
@normanmaurer
Copy link
Copy Markdown
Member

@netty-bot test this please

@normanmaurer
Copy link
Copy Markdown
Member

@netty-bot test this please

@normanmaurer normanmaurer requested a review from trustin March 19, 2019 10:38
@normanmaurer normanmaurer merged commit b36f750 into netty:4.1 Mar 22, 2019
normanmaurer pushed a commit that referenced this pull request Mar 22, 2019
Motivation:

The special case fixed in #8497 also requires that we keep a derived slice when trimming components in place, as done by the capacity(int) and discardReadBytes() methods.

Modifications:

Ensure that we keep a ref to trimmed components' original retained slice in capacity(int) and discardReadBytes() methods, so that it is released properly when the they are later freed. Add unit test which fails prior to the fix.

Result:

Edge case leak is eliminated.
@normanmaurer
Copy link
Copy Markdown
Member

@njhill thanks!

@njhill njhill deleted the cbb-leak-fix branch March 22, 2019 16:52
jtgrabowski pushed a commit to riptano/netty that referenced this pull request Oct 22, 2019
Motivation:

The special case fixed in netty#8497 also requires that we keep a derived slice when trimming components in place, as done by the capacity(int) and discardReadBytes() methods.

Modifications:

Ensure that we keep a ref to trimmed components' original retained slice in capacity(int) and discardReadBytes() methods, so that it is released properly when the they are later freed. Add unit test which fails prior to the fix.

Result:

Edge case leak is eliminated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants