Commit 44da431e by Ben Clayton

Regres: Avoid dereferencing a nil on process timeout.

"ProcessState contains information about an exited process, available after a call to Wait or Run" As ProcessState is only assigned after `Wait()` has completed, and this is run on another goroutine, it may be nil. Check before using it. Change-Id: I319f0703b3547186b53caca8d9d70bc5cd738d34 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43993Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent ab983012
...@@ -106,7 +106,7 @@ func Exec(timeout time.Duration, exe, wd string, env []string, args ...string) ( ...@@ -106,7 +106,7 @@ func Exec(timeout time.Duration, exe, wd string, env []string, args ...string) (
case <-time.NewTimer(timeout).C: case <-time.NewTimer(timeout).C:
c.Process.Signal(syscall.SIGINT) c.Process.Signal(syscall.SIGINT)
time.Sleep(time.Second * 3) time.Sleep(time.Second * 3)
if !c.ProcessState.Exited() { if c.ProcessState == nil || !c.ProcessState.Exited() {
log.Printf("Process %v still has not exited, killing\n", c.Process.Pid) log.Printf("Process %v still has not exited, killing\n", c.Process.Pid)
syscall.Kill(-c.Process.Pid, syscall.SIGKILL) syscall.Kill(-c.Process.Pid, syscall.SIGKILL)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment