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

[SPARK-29971][CORE][2.4] Fix buffer leaks in TransportFrameDecoder/TransportCipher #26660

Closed
wants to merge 1 commit into from

Conversation

normanmaurer
Copy link
Contributor

@normanmaurer normanmaurer commented Nov 25, 2019

What changes were proposed in this pull request?

  • Correctly release ByteBuf in TransportCipher in all cases
  • Move closing / releasing logic to handlerRemoved(...) so we are guaranteed that is always called.
  • Correctly release frameBuf it is not null when the handler is removed (and so also when the channel becomes inactive)

Why are the changes needed?

We need to carefully manage the ownership / lifecycle of ByteBuf instances so we don't leak any of these. We did not correctly do this in all cases:

  • when end up in invalid cipher state.
  • when partial data was received and the channel is closed before the full frame is decoded

Fixes netty/netty#9784.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Pass the newly added UTs.

…ortCipher`

- Correctly release `ByteBuf` in `TransportCipher` in all cases
- Move closing / releasing logic to `handlerRemoved(...)` so we are guaranteed that is always called.

We need to carefully manage the ownership / lifecycle of `ByteBuf` instances so we don't leak any of these. We did not correctly do this in all cases:
 - when end up in invalid cipher state.
 - when partial data was received and the channel is closed before the full frame is decoded

Fixes netty/netty#9784.

No.

Pass the newly added UTs.

Closes apache#26609 from normanmaurer/leaks_2_4.

Authored-by: Norman Maurer <norman_maurer@apple.com>
@dongjoon-hyun
Copy link
Member

Thank you, @normanmaurer .

@dongjoon-hyun
Copy link
Member

ok to test

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-29971][CORE] Fix buffer leaks in `TransportFrameDecoder/Transp… [SPARK-29971][CORE] Fix buffer leaks in TransportFrameDecoder/TransportCipher Nov 25, 2019
@dongjoon-hyun dongjoon-hyun changed the title [SPARK-29971][CORE] Fix buffer leaks in TransportFrameDecoder/TransportCipher [SPARK-29971][CORE][2.4] Fix buffer leaks in TransportFrameDecoder/TransportCipher Nov 25, 2019
@SparkQA
Copy link

SparkQA commented Nov 25, 2019

Test build #114393 has finished for PR 26660 at commit e8e6e60.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member

cc @vanzin

@vanzin
Copy link
Contributor

vanzin commented Nov 25, 2019

Merging to 2.4.

vanzin pushed a commit that referenced this pull request Nov 25, 2019
…ransportCipher`

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

- Correctly release `ByteBuf` in `TransportCipher` in all cases
- Move closing / releasing logic to `handlerRemoved(...)` so we are guaranteed that is always called.
- Correctly release `frameBuf` it is not null when the handler is removed (and so also when the channel becomes inactive)

### Why are the changes needed?

We need to carefully manage the ownership / lifecycle of `ByteBuf` instances so we don't leak any of these. We did not correctly do this in all cases:
 - when end up in invalid cipher state.
 - when partial data was received and the channel is closed before the full frame is decoded

Fixes netty/netty#9784.

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

No.

### How was this patch tested?

Pass the newly added UTs.

Closes #26660 from normanmaurer/leak_2_4.

Authored-by: Norman Maurer <norman_maurer@apple.com>
Signed-off-by: Marcelo Vanzin <vanzin@cloudera.com>
@dongjoon-hyun
Copy link
Member

Thank you so much, @vanzin and @normanmaurer !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants