sdboyer / gps

your dependencies have arrived
MIT License
270 stars 24 forks source link

`TestMonitoredCmd` is flaky #183

Closed spenczar closed 7 years ago

spenczar commented 7 years ago

On a fresh copy of gps, I ran glide install, then go test -v ., and got this:

=== RUN   TestMonitoredCmd
--- FAIL: TestMonitoredCmd (0.37s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x10833e8]

goroutine 49 [running]:
testing.tRunner.func1(0xc4203e41a0)
    /Users/snelson/go1.8/src/testing/testing.go:622 +0x29d
panic(0x14a87a0, 0x1a77730)
    /Users/snelson/go1.8/src/runtime/panic.go:489 +0x2cf
os.(*Process).signal(0x0, 0x1a506c0, 0x1a4a370, 0x0, 0x0)
    /Users/snelson/go1.8/src/os/exec_unix.go:56 +0x38
os.(*Process).Signal(0x0, 0x1a506c0, 0x1a4a370, 0x58c2bccc, 0x2a6d631b)
    /Users/snelson/go1.8/src/os/exec.go:121 +0x3f
os.(*Process).kill(0x0, 0x2a6d631b, 0x1a82420)
    /Users/snelson/go1.8/src/os/exec_posix.go:53 +0x43
os.(*Process).Kill(0x0, 0xc4203ce901, 0xc420043d78)
    /Users/snelson/go1.8/src/os/exec.go:106 +0x2b
github.com/sdboyer/gps.(*monitoredCmd).run(0xc4203c7d80, 0x0, 0x0)
    /Users/snelson/go/src/github.com/sdboyer/gps/cmd.go:41 +0x1a3
github.com/sdboyer/gps.TestMonitoredCmd(0xc4203e41a0)
    /Users/snelson/go/src/github.com/sdboyer/gps/cmd_test.go:26 +0x176
testing.tRunner(0xc4203e41a0, 0x153efd0)
    /Users/snelson/go1.8/src/testing/testing.go:657 +0x96
created by testing.(*T).Run
    /Users/snelson/go1.8/src/testing/testing.go:697 +0x2ca
exit status 2

A second run of go test -v . did not panic, so I assume this is some tricky race.

spenczar commented 7 years ago

Yep, looks like a data race, from go test -race. Full output in this gist: https://gist.github.com/spenczar/0548d384caa0f7bc950fc8dd9484c70a

sdboyer commented 7 years ago

derp derp - good catch, thank you!