From 6755f62592cfd0ee124c3e48b0bbb375cdd5e857 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 20 Oct 2017 11:17:22 +0200 Subject: syz-fuzzer: fix manager polling We need to always poll manager to send stats/maxsignal, we just need not request candidates if we have plenty of work. --- pkg/rpctype/rpctype.go | 7 ++++--- syz-fuzzer/fuzzer.go | 13 ++++++++----- syz-manager/manager.go | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/pkg/rpctype/rpctype.go b/pkg/rpctype/rpctype.go index efe9e4c1d..e3a9531d6 100644 --- a/pkg/rpctype/rpctype.go +++ b/pkg/rpctype/rpctype.go @@ -51,9 +51,10 @@ type NewInputArgs struct { } type PollArgs struct { - Name string - MaxSignal []uint32 - Stats map[string]uint64 + Name string + NeedCandidates bool + MaxSignal []uint32 + Stats map[string]uint64 } type PollRes struct { diff --git a/syz-fuzzer/fuzzer.go b/syz-fuzzer/fuzzer.go index 14a32f900..c5b35822d 100644 --- a/syz-fuzzer/fuzzer.go +++ b/syz-fuzzer/fuzzer.go @@ -346,15 +346,16 @@ func main() { } if poll || time.Since(lastPoll) > 10*time.Second { triageMu.RLock() - if len(candidates) > *flagProcs { - triageMu.RUnlock() + needCandidates := len(candidates) < *flagProcs + triageMu.RUnlock() + if !needCandidates && poll { continue } - triageMu.RUnlock() a := &PollArgs{ - Name: *flagName, - Stats: make(map[string]uint64), + Name: *flagName, + NeedCandidates: needCandidates, + Stats: make(map[string]uint64), } signalMu.Lock() a.MaxSignal = make([]uint32, 0, len(newSignal)) @@ -390,6 +391,8 @@ func main() { if err := manager.Call("Manager.Poll", a, r); err != nil { panic(err) } + Logf(1, "poll: candidates=%v inputs=%v signal=%v", + len(r.Candidates), len(r.NewInputs), len(r.MaxSignal)) if len(r.MaxSignal) != 0 { signalMu.Lock() for _, s := range r.MaxSignal { diff --git a/syz-manager/manager.go b/syz-manager/manager.go index 68adcdf62..2af810f78 100644 --- a/syz-manager/manager.go +++ b/syz-manager/manager.go @@ -996,10 +996,12 @@ func (mgr *Manager) Poll(a *PollArgs, r *PollRes) error { f.inputs = nil } - for i := 0; i < mgr.cfg.Procs && len(mgr.candidates) > 0; i++ { - last := len(mgr.candidates) - 1 - r.Candidates = append(r.Candidates, mgr.candidates[last]) - mgr.candidates = mgr.candidates[:last] + if a.NeedCandidates { + for i := 0; i < mgr.cfg.Procs && len(mgr.candidates) > 0; i++ { + last := len(mgr.candidates) - 1 + r.Candidates = append(r.Candidates, mgr.candidates[last]) + mgr.candidates = mgr.candidates[:last] + } } if len(mgr.candidates) == 0 { mgr.candidates = nil -- cgit mrf-deployment