Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@spavikevik
Copy link

@spavikevik spavikevik commented Jun 4, 2025

Addresses #9935.

Ok, the more I think about this, one thing seems clear.
If CharsetEncoder.encode is called with the endOfInput argument as true, no further characters are expected to be provided. At this point looping within the local endOfInput method shouldn't happen at all.
This change seems to fix the memory leak.

What I don't understand is how exactly under the current implementation do subsequent recurse calls of endOfInput seem to end up with overflow as result. This doesn't seem too obvious but my assumption is that the encoder itself keeps some internal state that is interpreted as overflow.

@CLAassistant
Copy link

CLAassistant commented Jun 4, 2025

CLA assistant check
All committers have signed the CLA.

@hearnadam
Copy link
Collaborator

Thank you for your contribution! Would it be possible for you to add tests that pass before and after this modification?

@spavikevik
Copy link
Author

spavikevik commented Jun 6, 2025

@hearnadam just to confirm I got it correctly, do you mean unit tests that verify the functionality of this pipeline method? Or do you have something else in mind by 'before and after'.

@hearnadam
Copy link
Collaborator

Unit tests for this method. If it passes before and after your PR, it should make sure other users won't see any issues.

@kyri-petrou
Copy link
Contributor

kyri-petrou commented Jun 8, 2025

I don't think the changes in the code are correct 🤔 encoder.flush needs to be called after we're done writing and it doesn't read from the input. This means that with the changes in this PR we won't be reading the full input if the buffer becomes full and we'll silently drop everything larger than the buffer size.

Can you please provide a reproduction of the code that you observed an OOM with?

@kyri-petrou
Copy link
Contributor

Got a working fix in #10011

@kyri-petrou kyri-petrou closed this Jul 6, 2025
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.

4 participants