Skip to content

zjit_bisect.rb: Fix pipe deadlock; log when timed out #14235

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

Merged
merged 1 commit into from
Aug 15, 2025

Conversation

XrXr
Copy link
Member

@XrXr XrXr commented Aug 15, 2025

I spent a long time bisecting some largish program before realising
that failure was in fact coming from the child timing out due to
zjit_bisect.rb not clearing the stdout and stderr pipe.

Fix the pipe dead lock by redirecting to /dev/null. This sacrifices
the debug output during boot, but for that we also get to remove
a lot of code and the dependency on Open3.


Warning Use communicate() rather than .stdin.write, .stdout.read or .stderr.read to avoid deadlocks due to any of the other OS pipe buffers filling up and blocking the child process.

https://docs.ruby-lang.org/en/master/Open3.html#method-i-popen3

Take care to avoid deadlocks. Output streams stdout and stderr have fixed-size buffers, so reading extensively from one but not the other can cause a deadlock when the unread buffer fills. To avoid that, stdout and stderr should be read simultaneously (using threads or IO.select).

@XrXr XrXr requested a review from a team August 15, 2025 00:10
I spent a long time bisecting some largish program before realising
that failure was in fact coming from the child timing out due to
zjit_bisect.rb not clearing the stdout and stderr pipe.

Fix the pipe dead lock by redirecting to /dev/null. This sacrifices
the debug output during boot, but for that we also get to remove
a lot of code and the dependency on Open3.
Copy link
Contributor

@tekknolagi tekknolagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you -- this is nice

@XrXr XrXr merged commit e409371 into ruby:master Aug 15, 2025
85 checks passed
@XrXr XrXr deleted the zjit-bisect branch August 15, 2025 20:57
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