proc/native/linux: tolerate ESRCH error in setCurrentBreakpoints

A thread could terminate between the point when we stop for a
breakpoint and the point where we send a stop signal to all threads, if
this happens setCurrentBreakpoints will fail with an error.

We should tolerate this.

For some reason this happens very frequently when running delve on
processes with the race detector enabed.
This commit is contained in:
aarzilli 2017-11-06 18:43:15 +01:00 committed by Derek Parker
parent 40ae277ab2
commit 94b50d0f60

@ -370,9 +370,14 @@ func (dbp *Process) wait(pid, options int) (int, *sys.WaitStatus, error) {
func (dbp *Process) setCurrentBreakpoints(trapthread *Thread) error { func (dbp *Process) setCurrentBreakpoints(trapthread *Thread) error {
for _, th := range dbp.threads { for _, th := range dbp.threads {
if th.CurrentBreakpoint == nil { if th.CurrentBreakpoint == nil {
err := th.SetCurrentBreakpoint() if err := th.SetCurrentBreakpoint(); err != nil {
if err != nil { if err == sys.ESRCH {
return err // This thread quit between the point where we received the breakpoint and
// the stop signal.
delete(dbp.threads, th.ID)
} else {
return err
}
} }
} }
} }