-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-135335: flush stdout/stderr in forkserver after preloading modules #135338
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
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
… if the defaults change elsewhere in the future)
…use a not-completely-awful name for the module to test.
Co-authored-by: Mikhail Efimov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Victor Stinner <[email protected]>
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 <[email protected]>
…nUqb_.rst Co-authored-by: Victor Stinner <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I just have a last suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…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 <[email protected]> Co-authored-by: Mikhail Efimov <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
GH-135670 is a backport of this pull request to the 3.14 branch. |
…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 <[email protected]> Co-authored-by: Mikhail Efimov <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
GH-135671 is a backport of this pull request to the 3.13 branch. |
Thanks for the bug report and the fix @duaneg. |
Thanks for the reviews, folks. |
…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 <[email protected]> Co-authored-by: Mikhail Efimov <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
…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 <[email protected]> Co-authored-by: Mikhail Efimov <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
Thanks for thorough working on this PR! |
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 |
Ok, I'll take a look. |
…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 <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
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.