Skip to content

[6.2][Macros] Mitigate plugin process 'wait' failure #81535

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

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented May 15, 2025

Cherry-pick #81517 (and #81547) into release/6.2

  • Explanation: We observed some cases where the compiler were waiting for macro plugins to exit for long time. To mitigate those issues, proactively terminate (SIGTERM) the plugin process, in addition to close the pipe and expecting the plugin exit itself. Also adjust the llvm::sys::Wait timeout from 1 to 10 seconds, because in the Wait implementation, it sets the alarm(SecondsToWait), then wait4(pid, ..) so the alarm can go off before the wait4 call. Also, make sure to close all the pipe file descriptor after duping them to stdio, which is not necessary, but it's a good thing to do.
  • Risk: Low. Although this terminates the plugins ungracefully, but since the plugins can't access filesystems, the risk is not high.
  • Testing: Passes the current test suite. No test added because we haven't been able to reproduce the hang.
  • Issues: rdar://150474701
  • Reviewer: Ben Barham (@bnbarham)

@rintaro rintaro requested a review from a team as a code owner May 15, 2025 18:39
@rintaro
Copy link
Member Author

rintaro commented May 15, 2025

@swift-ci Please test

Instead of expecting the plugin read `EOF` and exit, proactively
terminate the plugin and `wait` to reap it.

(cherry picked from commit 4a62ef8)

[Macros] 'close' unnecessary file descriptors in plugin process

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.

(cherry picked from commit 05948bc)
@rintaro rintaro force-pushed the 6.2-macros-wait-rdar150474701 branch from f405ed7 to 2416b58 Compare May 15, 2025 23:21
@rintaro
Copy link
Member Author

rintaro commented May 15, 2025

@swift-ci Please test

@rintaro rintaro merged commit 5c06176 into swiftlang:release/6.2 May 16, 2025
5 checks passed
@rintaro rintaro deleted the 6.2-macros-wait-rdar150474701 branch May 16, 2025 18:21
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