You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This hang occurred only in CI environments and only on Linux. Here's the sequence of events:
- Test terminates swbuild using SIGKILL
- OS reparents SWBBuildService (a subprocess of swbuild) to launchd (Darwin) / init (others)
- OS closes the file descriptors for the I/O pipes swbuild has connected to SWBBuildService
- SWBBuildService's read() loop indicates EOF due to the broken pipe
- SWBBuildService causes itself to exit
At this point, the getpgid loop should return ERSCH and terminate the test. However, SWBBuildService is sticking around as a zombie for an extended period of time without init reaping the pid, causing getpgid to never hit the termination state. This causes the test to hang indefinitely.
To fix this, there are two aspects:
- A timeout is added around the termination monitoring loop that forces the exit promise to be fulfilled with an error if a 30-second interval elapses without the process exiting
- We switch from using a getpgid loop to using a waitid loop, where the terminal state is that the process has _exited_... we don't care if the zombie hasn't been collected by init, only that it's not in a running state
This fixes the hang for both the Jenkins based CI as well as GitHub actions, and also insulates us against future hangs by ensuring the test will terminate with a timeout error instead of hanging indefinitely, so that we at least know _which_ test is the problem.
// We use getpgid() here to detect when the process has exited (it is not a child). Surprisingly, getpgid() is substantially faster than using kill(pid, 0) here because kill still returns success for zombies, and the service has been reparented to launchd. // ignore-unacceptable-language; POSIX API
148
-
do{
149
-
ifgetpgid(pid)<0{
150
-
// We expect the signal to eventually fail with "No such process".
0 commit comments