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

ConnectablePayloadWriter: avoid static exception that may leak memory #3047

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

ConnectablePayloadWriter uses a static IOException instance as a state and can propagate it to Subscriber. This opens a possibility for a memory leak if Subscriber or intermediate operators attach a suppressed exception to this static instance.

Modifications:

  • Create StacklessCancelledIOException and always use a new instance in case of cancellation;
  • Keep cancel() noop if outer.closed != null;

Result:

ConnectablePayloadWriter can not leak memory via static exception instance.

Motivation:

`ConnectablePayloadWriter` uses a static `IOException` instance as a
state and can propagate it to `Subscriber`. This opens a possibility for
a memory leak if `Subscriber` or intermediate operators attach a
suppressed exception to this static instance.

Modifications:
- Create `StacklessCancelledIOException` and always use a new instance
in case of cancellation;
- Keep `cancel()` noop if `outer.closed != null`;

Result:

`ConnectablePayloadWriter` can not leak memory via static exception
instance.
@idelpivnitskiy idelpivnitskiy merged commit ed0265c into apple:main Aug 21, 2024
11 checks passed
@idelpivnitskiy idelpivnitskiy deleted the cpw branch August 21, 2024 22:45
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 this pull request may close these issues.

3 participants