-
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
Weak error handling in ByteToMessageDecoder? #9812
Milestone
Comments
@martinfurmanski I think you are right. How about using a static ByteBuf expandCumulation(ByteBufAllocator alloc, ByteBuf cumulation, int readable) {
ByteBuf newCumulation = alloc.buffer(cumulation.readableBytes() + readable);
try {
newCumulation.writeBytes(cumulation);
cumulation.release();
return cumulation = newCumulation;
} finally {
if (newCumulation != cumulation) {
newCumulation.release();
}
}
} |
Sounds like a plan... @martinfurmanski do you want to provide a PR ? |
@njhill @normanmaurer Thanks for confirming the issue. I'll attempt a PR shortly! |
martinfurmanski
added a commit
to martinfurmanski/netty
that referenced
this issue
Nov 28, 2019
Motivation: The buffer which the decoder allocates for the expansion can be leaked if there is a subsequent issue writing to it. Modifications: The error handling has been improved so that the new buffer always is released on failure in the expand. Result: The decoder will not leak in this scenario any more. Fixes: netty#9812
normanmaurer
pushed a commit
that referenced
this issue
Nov 28, 2019
Motivation: The buffer which the decoder allocates for the expansion can be leaked if there is a subsequent issue writing to it. Modifications: The error handling has been improved so that the new buffer always is released on failure in the expand. Result: The decoder will not leak in this scenario any more. Fixes: #9812
@martinfurmanski thanks again for the patch |
normanmaurer
pushed a commit
that referenced
this issue
Nov 28, 2019
Motivation: The buffer which the decoder allocates for the expansion can be leaked if there is a subsequent issue writing to it. Modifications: The error handling has been improved so that the new buffer always is released on failure in the expand. Result: The decoder will not leak in this scenario any more. Fixes: #9812
Thank you both for the review and acceptance! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have this stack trace from 4.1.32 for a leak report, but the code is not significantly changed in this area in 4.1.43 as far as I can see.
My contention is that the error handling is weak around
expandCumulation
because for example:if this fails after
alloc.buffer
then that buffer gets completely lost. Even up the stack inByteToMessageDecoder$1.cumulate
(MERGE_CUMULATOR) if writeBytes fails then the returned buffer gets lost.Thoughts?
The text was updated successfully, but these errors were encountered: