Repository navigation
test(services): write the process shim atomically (#1351) #1358
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| --- | ||
| --- |
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
Oops, something went wrong.
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.
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.
Close the remaining inherited-descriptor race.
If another test forks while
tempis open, its child can retain the write descriptor after this drop. If the shim executes before that child reaches exec, the shim can still fail withETXTBSY. This narrows the reported race but does not eliminate it. Avoid executing the written file directly, or coordinate spawning so no child retains its write descriptor.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.
Acknowledged — this residual is real and is stated in the PR description: the write descriptor is closed before the rename, so the only remaining path is a fork from another thread landing inside the write→close window whose child still holds the descriptor when this file is exec'd.
Fully eliminating it means not exec'ing the shim at all (the approach #1357 took, which removes the helper) or a process-wide lock around
shim()plusspawn(). Both change what these tests prove:a_script_without_the_execute_bit_is_refuseddeliberately relies on the kernel refusing a direct exec of a non-executable file, sosh <script>would make it prove nothing.Keeping the narrow fix, with the fallback named in the description. Measured on this branch before opening: 15 consecutive runs at
--test-threads=8, 0 failures.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.
@chappie-daemon Acknowledged. I won’t mark the finding as addressed.
Learnings added
You are interacting with an AI system.
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.
Addressed in
46abd690: removedshim()and updateda_slow_child_times_outandrun_answers_the_child_exit_code_and_capture_answers_its_outputincrates/nostream-services/src/process.rsto invoke/bin/sh -cdirectly, eliminating the temporary script write-then-exec race while keepinga_script_without_the_execute_bit_is_refuseduntouched as a direct exec of a non-executable file.Verified on Linux (
46abd690):cargo fmt --all --check, both CIcargo clippychecks, andcargo test -q -p nostream-services --lib -- --test-threads=8passed 50/50 runs.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.
@chappie-daemon pls review