Skip to content

[Macros] Mitigate plugin process 'wait' failure #81517

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 3 commits into from
May 15, 2025

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented May 14, 2025

Previously, the compiler waited the plugin process with llvm::sys::Wait(process, /*SecondsToWait=*/1). But in the Wait implementation, it sets the alarm(SecondsToWait), then wait4(process.Pid, ..) so if the alarm fires before the wait4 call, it may miss the timeout and can wait indefinitely. To mitigate that risk, use 10 for the timeout value.

And terminate the plugin process, then wait to reap it, instead of expecting the plugin read EOF and exit itself.

Also, close all the pipe file descriptors in the child process after duping them to the standard I/O. This is not necessary but it's a good thing to do anyway.

rdar://150474701

Previously, the compiler waited the plugin process with
`llvm::sys::Wait(pid, /*SecondsToWait=*/1)`. But in the `Wait`
implementation, it sets the `alarm(SecondsToWait)`, then
`wait4(pid, ..)` so if the alarm fires before the `wait4` call,
it may miss the timeout and can wait indefinitely. To mitigate that
risk,use `10` for the timeout value.

rdar://150474701
@rintaro
Copy link
Member Author

rintaro commented May 14, 2025

@swift-ci Please smoke test

@rintaro rintaro force-pushed the macros-wait-rdar150474701 branch from 0463484 to 45d3508 Compare May 14, 2025 19:54
Close all the pipe file descriptors in the child process after duping
them to the standard I/O. This is not necessary but it's a good thing to
do anyway.
@rintaro rintaro force-pushed the macros-wait-rdar150474701 branch from 45d3508 to 05948bc Compare May 14, 2025 19:54
@rintaro
Copy link
Member Author

rintaro commented May 14, 2025

@swift-ci Please smoke test

Instead of expecting the plugin read `EOF` and exit, proactively
terminate the plugin and `wait` to reap it.
@rintaro
Copy link
Member Author

rintaro commented May 14, 2025

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented May 14, 2025

@swift-ci Please smoke test macOS

@rintaro rintaro merged commit a0aad5c into swiftlang:main May 15, 2025
3 checks passed
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.

2 participants