Skip to content

ByteToMessageDecoder#handlerRemoved may release cumulation buffer pre…#6728

Closed
Scottmitch wants to merge 1 commit into
netty:4.1from
Scottmitch:byte_msg_decode
Closed

ByteToMessageDecoder#handlerRemoved may release cumulation buffer pre…#6728
Scottmitch wants to merge 1 commit into
netty:4.1from
Scottmitch:byte_msg_decode

Conversation

@Scottmitch
Copy link
Copy Markdown
Member

…maturely

Motivation:
ByteToMessageDecoder#handlerRemoved will immediately release the cumulation buffer, but it is possible that a child class may still be using this buffer, and therefore use a dereferenced buffer.

Modifications:

  • ByteToMessageDecoder#handlerRemoved and ByteToMessageDecoder#decode should coordinate to avoid the case where a child class is using the cumulation buffer but ByteToMessageDecoder releases that buffer.

Result:
Child classes of ByteToMessageDecoder are less likely to reference a released buffer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just not merge both into one int ? No need to have two boolean here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 booleans was a bit simpler but I will just use a byte if we want to be more definitive about memory usage.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was not about memory but more about "logic" as it can only be in one state of both. But this is just a nit. So feel free to ignore

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done ... I changed to a byte anyways :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also have this test in ReplayingDecoderTest ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch ... done

…maturely

Motivation:
ByteToMessageDecoder#handlerRemoved will immediately release the cumulation buffer, but it is possible that a child class may still be using this buffer, and therefore use a dereferenced buffer.

Modifications:
- ByteToMessageDecoder#handlerRemoved and ByteToMessageDecoder#decode should coordinate to avoid the case where a child class is using the cumulation buffer but ByteToMessageDecoder releases that buffer.

Result:
Child classes of ByteToMessageDecoder are less likely to reference a released buffer.
@Scottmitch
Copy link
Copy Markdown
Member Author

4.1 (ce2ce9d) 4.0 (23fc5d7)

@Scottmitch Scottmitch closed this May 10, 2017
@Scottmitch Scottmitch deleted the byte_msg_decode branch May 10, 2017 18:19
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.

2 participants