forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spawning against materialized binaries works.
It's generically unsafe to fork+exec against binaries written out in a multithreaded program when concurrent forks are possible. Even if all files are opened for writing with O_CLOEXEC (which is the case for Rust) if thread1 opens a file for writing and then thread2 forks, thread2 will hold an open file descriptor. If thread2's subsequent exec is delayed past the fork+exec thread1 does against the file it wrote, then the thread1 fork+exec'd process will encounter ETXTBSY. OSX "solves" this by retrying some number of times when it hits ETXTBSY, but Linux does not attempt this hack. O_CLOFORK has been proposed and adopted by some unices, but not Linux. As such we need to make some tradeoff to allow this use case. This change introduces a lock around process spawns (fork+exec) to prevent interleaved fork / exec whenever there is a spawn that we know exec's a binary we wrote out. Fixes pantsbuild#10507 [ci skip-build-wheels]
- Loading branch information
Showing
5 changed files
with
64 additions
and
147 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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