vm: fix "kill fuzzer on first kernel bug"

The problem with that commit is that for GCE implementation
we immidiately kill console connection too when receive diagnose signal.
This leads to truncated output.
This commit is contained in:
Dmitry Vyukov 2018-07-29 10:07:30 +02:00
parent ebf656d79b
commit 419000cc0a
2 changed files with 23 additions and 28 deletions

View File

@ -49,17 +49,16 @@ type Pool struct {
}
type instance struct {
env *vmimpl.Env
cfg *Config
GCE *gce.Context
debug bool
name string
ip string
gceKey string // per-instance private ssh key associated with the instance
sshKey string // ssh key
sshUser string
closed chan bool
diagnose chan bool
env *vmimpl.Env
cfg *Config
GCE *gce.Context
debug bool
name string
ip string
gceKey string // per-instance private ssh key associated with the instance
sshKey string // ssh key
sshUser string
closed chan bool
}
func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
@ -172,17 +171,16 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
}
ok = true
inst := &instance{
env: pool.env,
cfg: pool.cfg,
debug: pool.env.Debug,
GCE: pool.GCE,
name: name,
ip: ip,
gceKey: gceKey,
sshKey: sshKey,
sshUser: sshUser,
closed: make(chan bool),
diagnose: make(chan bool, 1),
env: pool.env,
cfg: pool.cfg,
debug: pool.env.Debug,
GCE: pool.GCE,
name: name,
ip: ip,
gceKey: gceKey,
sshKey: sshKey,
sshUser: sshUser,
closed: make(chan bool),
}
return inst, nil
}
@ -316,6 +314,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
}
go func() {
retry:
select {
case <-time.After(timeout):
signal(vmimpl.ErrTimeout)
@ -323,8 +322,6 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
signal(vmimpl.ErrTimeout)
case <-inst.closed:
signal(fmt.Errorf("instance closed"))
case <-inst.diagnose:
ssh.Process.Kill()
case err := <-merger.Err:
con.Process.Kill()
ssh.Process.Kill()
@ -360,10 +357,6 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
}
func (inst *instance) Diagnose() bool {
select {
case inst.diagnose <- true:
default:
}
return false
}

View File

@ -476,6 +476,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
}
go func() {
retry:
select {
case <-time.After(timeout):
signal(vmimpl.ErrTimeout)
@ -483,6 +484,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
signal(vmimpl.ErrTimeout)
case <-inst.diagnose:
cmd.Process.Kill()
goto retry
case err := <-inst.merger.Err:
cmd.Process.Kill()
if cmdErr := cmd.Wait(); cmdErr == nil {