Skip to content

Commit be25ea2

Browse files
committed
[Macros] Mitigate plugin process 'wait' failure
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
1 parent 78234e2 commit be25ea2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/AST/PluginRegistry.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,10 @@ LoadedExecutablePlugin::PluginProcess::~PluginProcess() {
219219
// that. Usually when the pipe is closed above, the plugin detects the EOF in
220220
// the stdin and exits immediately, so this usually doesn't wait for the
221221
// timeout. Note that we can't use '0' because it performs a non-blocking
222-
// wait, which make the plugin a zombie if it hasn't exited.
223-
llvm::sys::Wait(process, /*SecondsToWait=*/1);
222+
// wait, which make the plugin a zombie if it hasn't exited. We don't use
223+
// a small number like '1' because the timeout alarm(3) can fire before the
224+
// wait4(2).
225+
llvm::sys::Wait(process, /*SecondsToWait=*/10);
224226
}
225227

226228
ssize_t LoadedExecutablePlugin::PluginProcess::read(void *buf,

0 commit comments

Comments
 (0)