From 021e0b5aa4505aa436e271256e617dcd86a9532a Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 23 Jul 2024 14:21:59 +0200 Subject: [PATCH] vm: check preemption string only for gce instances Fixes #5028 --- vm/gce/gce.go | 5 +++-- vm/vm.go | 6 +++++- vm/vmimpl/vmimpl.go | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/vm/gce/gce.go b/vm/gce/gce.go index e65ee836b81d..19fd1eecdec2 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -36,8 +36,9 @@ import ( func init() { vmimpl.Register("gce", vmimpl.Type{ - Ctor: ctor, - Overcommit: true, + Ctor: ctor, + Overcommit: true, + Preemptible: true, }) } diff --git a/vm/vm.go b/vm/vm.go index cc7c656cde66..ca22f2be188b 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -43,6 +43,7 @@ import ( type Pool struct { impl vmimpl.Pool + typ vmimpl.Type workdir string template string timeouts targets.Timeouts @@ -128,6 +129,7 @@ func Create(cfg *mgrconfig.Config, debug bool) (*Pool, error) { } return &Pool{ impl: impl, + typ: typ, workdir: env.Workdir, template: cfg.WorkdirTemplate, timeouts: cfg.Timeouts, @@ -420,7 +422,9 @@ func (mon *monitor) extractError(defaultError string) *report.Report { if defaultError != noOutputCrash || diagWait { mon.waitForOutput() } - if bytes.Contains(mon.output, []byte(executorPreemptedStr)) { + // Check the executorPreemptedStr only for preemptible instances since executor can print + // the string spuriously in some cases (gets SIGTERM from test program somehow). + if mon.inst.pool.typ.Preemptible && bytes.Contains(mon.output, []byte(executorPreemptedStr)) { return nil } if defaultError == "" && mon.reporter.ContainsCrash(mon.output[mon.matchPos:]) { diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go index ac38a6634dfa..564c3e66e451 100644 --- a/vm/vmimpl/vmimpl.go +++ b/vm/vmimpl/vmimpl.go @@ -133,6 +133,10 @@ type Type struct { // It's possible to create out-of-thin-air instances of this type. // Out-of-thin-air instances are used by syz-ci for image testing, patch testing, bisection, etc. Overcommit bool + // Instances of this type can be preempted and lost connection as the result. + // For preempted instances executor prints "SYZ-EXECUTOR: PREEMPTED" and then + // the host understands that the lost connection was expected and is not a bug. + Preemptible bool } type ctorFunc func(env *Env) (Pool, error)