-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Unbounded growth in SpooledTemporaryFile.writelines()
#127371
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
Comments
Thank you for your report and PR @bertptrs. I do not think that it is worth to backport this change, it looks more as a new feature (minor improvement of memory use). |
@serhiy-storchaka I personally do think is better to backport, as it is a security issue. I discovered this bug because of a DoS issue in our code base. The developer who wrote the original code reasonably assumed that he had set a buffer size limit, while he effectively hadn't. How much effort is it to backport this? |
I'm not strictly against it, I just have doubts. I left this on the release manager, @Yhg1s. |
…thonGH-127372) (cherry picked from commit cb67b44) Co-authored-by: Bert Peters <[email protected]>
Backporting the fix makes sense to me. |
…thonGH-127372) (cherry picked from commit cb67b44) Co-authored-by: Bert Peters <[email protected]>
Thanks for backporting! Looking forward to seeing these changes drop in a release. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
SpooledTemporaryFile
provides a temporary file backed by a buffer in memory that spills over to disk when it gets too large. However, thewritelines()
method only checks whether it should roll over after the entire lines iterator is exhausted. This causes unexpectedly high memory use when feeding it large iterators.With the above code, one might expect that the buffer doesn't grow (much) past 1024 bytes, but it grows to almost three times that size before finally rolling over.
CPython versions tested on:
3.12, 3.13, CPython main branch
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: