-
Notifications
You must be signed in to change notification settings - Fork 219
Streamline file descriptor handling during spawning #596
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
Conversation
* Leak of the output pipe file descriptors if control pipe can't be opened. * Leak of posix file actions memory if the control pipes can't be created. * Descriptors leak of unrelated tasks into spawned task (linux, win). * Windows code improperly inheriting the control file descriptors. * A race condition in the control channel parsing on windows resulting in a potential double-free. rdar://56800263
|
@swift-ci please smoke test |
|
|
||
| // Close the child ends of the forwarded output and control pipes. | ||
| controlPipeChildEnd.close(); | ||
| outputPipeChildEnd.close(); |
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.
The child ends should be closed under the lock because they are potentially inheritable by other processes if we are to spawn one in a parallel thread.
| std::shared_ptr<ManagedDescriptor> outputFdShared | ||
| = std::make_shared<ManagedDescriptor>(std::move(outputPipeParentEnd)); | ||
| std::shared_ptr<ManagedDescriptor> controlFdShared | ||
| = std::make_shared<ManagedDescriptor>(std::move(controlPipeParentEnd)); |
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.
The shared_ptrs are necessary because we disabled the copy constructor on a ManagedDescriptor, which makes it impossible to copy lambdas around, which makes it impossible to capture it in a lambda with a purpose of forwarding it further.
|
@gmittert if you have a chance to check the windows portion that'd be great! |
|
@vlm Sure! Might take me a bit though, I'm out of office this week. |
rdar://56800263