jpillora / overseer

Monitorable, gracefully restarting, self-upgrading binaries in Go (golang)
MIT License
2.32k stars 207 forks source link

May be this tool has some data race problem #26

Open wgffgw opened 6 years ago

wgffgw commented 6 years ago

When I build my project using "go build -race" with this tool, after shutdown the process by "Ctrl+C", I found any data race warning, like below : WARNING: DATA RACE Read at 0x00c420374de0 by goroutine 15: github.com/jpillora/overseer.(master).handleSignal() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:135 +0x115 github.com/jpillora/overseer.(master).setupSignalling.func1() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:113 +0xa1

Previous write at 0x00c420374de0 by main goroutine: github.com/jpillora/overseer.(master).fork() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:350 +0x18f github.com/jpillora/overseer.(master).forkLoop() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:339 +0x38 github.com/jpillora/overseer.(*master).run() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:65 +0x172 github.com/jpillora/overseer.runErr() /home/work/gowork/src/github.com/jpillora/overseer/overseer.go:162 +0x27f github.com/jpillora/overseer.Run() /home/work/gowork/src/github.com/jpillora/overseer/overseer.go:99 +0x9d main.main_overseer() /home/work/gowork/src/go-entry/main/main.go:59 +0x128 main.main() /home/work/gowork/src/go-entry/main/main.go:49 +0x358

Goroutine 15 (running) created at: github.com/jpillora/overseer.(master).setupSignalling() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:115 +0x161 github.com/jpillora/overseer.(master).run() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:56 +0xfb github.com/jpillora/overseer.runErr() /home/work/gowork/src/github.com/jpillora/overseer/overseer.go:162 +0x27f github.com/jpillora/overseer.Run() /home/work/gowork/src/github.com/jpillora/overseer/overseer.go:99 +0x9d main.main_overseer() /home/work/gowork/src/go-entry/main/main.go:59 +0x128 main.main() /home/work/gowork/src/go-entry/main/main.go:49 +0x358

================== WARNING: DATA RACE Read at 0x00c4203a20a0 by goroutine 15: github.com/jpillora/overseer.(master).handleSignal() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:135 +0x2e2 github.com/jpillora/overseer.(master).setupSignalling.func1() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:113 +0xa1

Previous write at 0x00c4203a20a0 by main goroutine: os/exec.Command() /home/work/soft/go/src/os/exec/exec.go:133 +0x15b github.com/jpillora/overseer.(master).fork() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:347 +0x162 github.com/jpillora/overseer.(master).forkLoop() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:339 +0x38 github.com/jpillora/overseer.(*master).run() /home/work/gowork/src/github.com/jpillora/overseer/proc_master.go:65 +0x172 github.com/jpillora/overseer.runErr() /home/work/gowork/src/github.com/jpillora/overseer/overseer.go:162 +0x27f github.com/jpillora/overseer.Run() /home/work/gowork/src/github.com/jpillora/overseer/overseer.go:99 +0x9d main.main_overseer() /home/work/gowork/src/go-entry/main/main.go:59 +0x128 main.main() /home/work/gowork/src/go-entry/main/main.go:49 +0x358

lookfirst commented 6 years ago

Interesting, since handleSignal is called in a goroutine, any access to mp properties should probably be mutex locked on the master struct. In practice, this probably isn't a huge deal, but could be cleaned up for sure. @jpillora, what do you think?

jpillora commented 6 years ago

Yeah true, though signals occur very infrequently so would be a very rare crash. PR 😁?