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

Fix start test program race condition #33

Merged
merged 4 commits into from
Mar 14, 2024
Merged

Conversation

d-maurer
Copy link
Contributor

Fixes #32.

#32 is caused by a race condition between the SIGCHLD signal handler and the wait in subprocess.call used to start the start-test-program. If the signal handler is activated before the wait call, the wait can no longer determine the process' exit status and (erroneously) claims the process exited successfully. In those cases, the start test ends prematurely.

This PR avoids the problem by letting the SIGCHLD handler record the exit status for unknown processes. If the start test gets a successful exit from subprocess, it verifies that the SIGCHLD handler has not recorded a contradicting exit status.

The race is very rare. To provoke it (for testing), you can uncomment the line import time; time.sleep(0.01) in zdaemon.zdrun.Subprocess.test.

@d-maurer d-maurer requested review from do3cc, icemac and dataflake March 14, 2024 06:47
src/zdaemon/zdrun.py Outdated Show resolved Hide resolved
@icemac
Copy link
Member

icemac commented Mar 14, 2024

Thank you for tackling this issue.

Co-authored-by: Michael Howitz <icemac@gmx.net>
Copy link
Member

@do3cc do3cc left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this!

@d-maurer d-maurer merged commit a81a561 into master Mar 14, 2024
13 checks passed
@d-maurer d-maurer deleted the fix_start-test-program branch March 14, 2024 08:32
@d-maurer
Copy link
Contributor Author

Thanks for tackling this!

Your help has been essential!

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.

PyPy3 tests break
4 participants