Skip to content
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

system_command: fix potential issue of stderr not being read #16162

Merged
merged 1 commit into from Oct 30, 2023

Conversation

Bo98
Copy link
Member

@Bo98 Bo98 commented Oct 29, 2023

This is a blind, possible fix for test flakiness surrounding stderr in the system_command tests. I was not able to reproduce the issue locally but did identify a possible cause.

The potential bad flow I've identified here:

  1. Assume ProcessTerminatedInterrupt is received before IO.select signals readable streams (very narrow window that I cannot reproduce - maybe will happen in VMs)
  2. On receiving this, readable_sources is set to all streams and pending_interrupt is set to true
  3. We run readable_sources.none? to loop through and read all streams. However none? as it was written was guaranteed to short-circuit after the first stream as all possible paths would lead it to returning true (EOF on first stream will return value of sources.any? which will be true given we haven't got to the second stream yet).
  4. We exit the until loop because of pending_interrupt with that second stream not being read yet.

The correct behaviour should be to read all readable_sources so I've adjusted the logic slightly to make sure that is the case.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Worth a try, thanks @Bo98!

@MikeMcQuaid MikeMcQuaid merged commit 53107a5 into Homebrew:master Oct 30, 2023
27 checks passed
@Bo98 Bo98 deleted the system_command-stderr-fix branch October 30, 2023 14:43
@github-actions github-actions bot added the outdated PR was locked due to age label Nov 30, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants