diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-09-11 12:22:13 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-09-12 16:53:03 +0000 |
| commit | 73e8a465188a43a0d783006a7cb71d0931a08492 (patch) | |
| tree | ff7e830c72d49bd327914563bc18065a526dbbe8 /syz-manager/manager.go | |
| parent | 0c82e9ad8718dffc85fe43f728498ee39bbba25d (diff) | |
pkg/manager: remove ReproLoop.StartReproduction()
It used to race with Enqueue(), which made it more complicated to write
reproducible tests. Also, there's really no reason to separate
StartReproduction() and Loop().
Diffstat (limited to 'syz-manager/manager.go')
| -rw-r--r-- | syz-manager/manager.go | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/syz-manager/manager.go b/syz-manager/manager.go index 71168fb82..e45a18a74 100644 --- a/syz-manager/manager.go +++ b/syz-manager/manager.go @@ -298,7 +298,6 @@ func RunManager(mode Mode, cfg *mgrconfig.Config) { mgr.reproLoop = manager.NewReproLoop(mgr, mgr.vmPool.Count()-mgr.cfg.FuzzingVMs, mgr.cfg.DashboardOnlyRepro) ctx := vm.ShutdownCtx() go mgr.processFuzzingResults(ctx) - go mgr.reproLoop.Loop(ctx) mgr.pool.Loop(ctx) } @@ -992,7 +991,7 @@ func (mgr *Manager) getNewRepros() [][]byte { func (mgr *Manager) addNewCandidates(candidates []fuzzer.Candidate) { mgr.mu.Lock() if mgr.phase == phaseTriagedCorpus { - mgr.phase = phaseQueriedHub + mgr.setPhaseLocked(phaseQueriedHub) } mgr.mu.Unlock() if mgr.cfg.Experimental.ResetAccState { @@ -1127,7 +1126,7 @@ func (mgr *Manager) MachineChecked(features flatrpc.Feature, enabledSyscalls map stat.Simple, stat.NoGraph, stat.Link("/syscalls")) statSyscalls.Add(len(enabledSyscalls)) corpus := mgr.loadCorpus() - mgr.phase = phaseLoadedCorpus + mgr.setPhaseLocked(phaseLoadedCorpus) opts := mgr.defaultExecOpts() if mgr.mode == ModeFuzzing { @@ -1300,21 +1299,30 @@ func (mgr *Manager) fuzzerLoop(fuzzer *fuzzer.Fuzzer) { mgr.serv.TriagedCorpus() } if mgr.cfg.HubClient != "" { - mgr.phase = phaseTriagedCorpus + mgr.setPhaseLocked(phaseTriagedCorpus) go mgr.hubSyncLoop(pickGetter(mgr.cfg.HubKey)) } else { - mgr.phase = phaseTriagedHub - mgr.reproLoop.StartReproduction() + mgr.setPhaseLocked(phaseTriagedHub) } } else if mgr.phase == phaseQueriedHub { - mgr.phase = phaseTriagedHub - mgr.reproLoop.StartReproduction() + mgr.setPhaseLocked(phaseTriagedHub) } mgr.mu.Unlock() } } } +func (mgr *Manager) setPhaseLocked(newPhase int) { + if mgr.phase == newPhase { + panic("repeated phase update") + } + if newPhase == phaseTriagedHub { + // Start reproductions. + go mgr.reproLoop.Loop(vm.ShutdownCtx()) + } + mgr.phase = newPhase +} + func (mgr *Manager) needMoreCandidates() bool { return mgr.fuzzer.Load().CandidateTriageFinished() } @@ -1324,8 +1332,7 @@ func (mgr *Manager) hubIsUnreachable() { mgr.mu.Lock() if mgr.phase == phaseTriagedCorpus { dash = mgr.dash - mgr.phase = phaseTriagedHub - mgr.reproLoop.StartReproduction() + mgr.setPhaseLocked(phaseTriagedHub) log.Errorf("did not manage to connect to syz-hub; moving forward") } mgr.mu.Unlock() |
