gh-135335: flush stdout/stderr in forkserver after preloading modules#135338
Merged
vstinner merged 15 commits intopython:mainfrom Jun 18, 2025
Merged
gh-135335: flush stdout/stderr in forkserver after preloading modules#135338vstinner merged 15 commits intopython:mainfrom
vstinner merged 15 commits intopython:mainfrom
Conversation
…odules If a preloaded module writes to stdout or stderr, and the stream is buffered, child processes will inherit the buffered data after forking. Attempt to prevent this by flushing the streams after preload.
...or at least produce more useful output if they fail
efimov-mikhail
requested changes
Jun 11, 2025
… if the defaults change elsewhere in the future)
vstinner
reviewed
Jun 17, 2025
…use a not-completely-awful name for the module to test.
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
vstinner
reviewed
Jun 17, 2025
vstinner
reviewed
Jun 17, 2025
vstinner
reviewed
Jun 17, 2025
Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
reviewed
Jun 17, 2025
Misc/NEWS.d/next/Library/2025-06-10-21-42-04.gh-issue-135335.WnUqb_.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Victor Stinner <vstinner@python.org>
…nUqb_.rst Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
approved these changes
Jun 18, 2025
Member
vstinner
left a comment
There was a problem hiding this comment.
LGTM. I just have a last suggestion.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Jun 18, 2025
…odules (pythonGH-135338) If a preloaded module writes to stdout or stderr, and the stream is buffered, child processes will inherit the buffered data after forking. Attempt to prevent this by flushing the streams after preload. (cherry picked from commit 9877d19) Co-authored-by: Duane Griffin <duaneg@dghda.com> Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
|
GH-135670 is a backport of this pull request to the 3.14 branch. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Jun 18, 2025
…odules (pythonGH-135338) If a preloaded module writes to stdout or stderr, and the stream is buffered, child processes will inherit the buffered data after forking. Attempt to prevent this by flushing the streams after preload. (cherry picked from commit 9877d19) Co-authored-by: Duane Griffin <duaneg@dghda.com> Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
|
GH-135671 is a backport of this pull request to the 3.13 branch. |
Member
|
Thanks for the bug report and the fix @duaneg. |
Contributor
Author
|
Thanks for the reviews, folks. |
vstinner
added a commit
that referenced
this pull request
Jun 18, 2025
…modules (GH-135338) (#135671) gh-135335: flush stdout/stderr in forkserver after preloading modules (GH-135338) If a preloaded module writes to stdout or stderr, and the stream is buffered, child processes will inherit the buffered data after forking. Attempt to prevent this by flushing the streams after preload. (cherry picked from commit 9877d19) Co-authored-by: Duane Griffin <duaneg@dghda.com> Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
added a commit
that referenced
this pull request
Jun 18, 2025
…modules (GH-135338) (#135670) gh-135335: flush stdout/stderr in forkserver after preloading modules (GH-135338) If a preloaded module writes to stdout or stderr, and the stream is buffered, child processes will inherit the buffered data after forking. Attempt to prevent this by flushing the streams after preload. (cherry picked from commit 9877d19) Co-authored-by: Duane Griffin <duaneg@dghda.com> Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
Member
|
Thanks for thorough working on this PR! |
Contributor
Author
Well, as it happens, I would love #132574 to get a review 🙂 It is a very simple bug and fix: an off-by-one error, that allows an out-of-bounds read, which affects basic string operations like |
Member
|
Ok, I'll take a look. |
lkollar
pushed a commit
to lkollar/cpython
that referenced
this pull request
Jun 19, 2025
…odules (python#135338) If a preloaded module writes to stdout or stderr, and the stream is buffered, child processes will inherit the buffered data after forking. Attempt to prevent this by flushing the streams after preload. Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
Pranjal095
pushed a commit
to Pranjal095/cpython
that referenced
this pull request
Jul 12, 2025
…odules (python#135338) If a preloaded module writes to stdout or stderr, and the stream is buffered, child processes will inherit the buffered data after forking. Attempt to prevent this by flushing the streams after preload. Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
taegyunkim
pushed a commit
to taegyunkim/cpython
that referenced
this pull request
Aug 4, 2025
…odules (python#135338) If a preloaded module writes to stdout or stderr, and the stream is buffered, child processes will inherit the buffered data after forking. Attempt to prevent this by flushing the streams after preload. Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
Agent-Hellboy
pushed a commit
to Agent-Hellboy/cpython
that referenced
this pull request
Aug 19, 2025
…odules (python#135338) If a preloaded module writes to stdout or stderr, and the stream is buffered, child processes will inherit the buffered data after forking. Attempt to prevent this by flushing the streams after preload. Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a preloaded module writes to stdout or stderr, and the stream is buffered, child processes will inherit the buffered data after forking. Attempt to prevent this by flushing the streams after preload.