From 5ad1a162959d6df7712dc93cffe128322b11d7af Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 5 Nov 2024 17:33:59 +0100 Subject: pkg/repro: accept a cancellable context Refactor pkg/repro to accept a context.Context object. This will make it look more similar to other package interfaces and will eventually let us abort currently running repro jobs without having to shut down the whole application. Simplify the code by factoring out the parameters common both to RunSyzRepro() and RunCRepro(). --- tools/syz-diff/diff.go | 16 ++++++++++++---- tools/syz-repro/repro.go | 7 ++++++- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/syz-diff/diff.go b/tools/syz-diff/diff.go index c3da6c8ec..6549aed70 100644 --- a/tools/syz-diff/diff.go +++ b/tools/syz-diff/diff.go @@ -207,8 +207,13 @@ func (dc *diffContext) RunRepro(crash *manager.Crash) *manager.ReproResult { dc.reproAttempts[crash.Title]++ dc.mu.Unlock() - res, stats, err := repro.Run(crash.Output, dc.new.cfg, dc.new.features, - dc.new.reporter, dc.new.pool, repro.Fast) + res, stats, err := repro.Run(context.Background(), crash.Output, repro.Environment{ + Config: dc.new.cfg, + Features: dc.new.features, + Reporter: dc.new.reporter, + Pool: dc.new.pool, + Fast: true, + }) if res != nil && res.Report != nil { dc.mu.Lock() dc.reproAttempts[res.Report.Title] = maxReproAttempts @@ -474,8 +479,11 @@ func (rr *reproRunner) Run(r *repro.Result) { if err != nil { return } - result, err = ret.RunSyzProg(r.Prog.Serialize(), max(r.Duration, time.Minute), opts, - instance.SyzExitConditions) + result, err = ret.RunSyzProg(instance.ExecParams{ + SyzProg: r.Prog.Serialize(), + Duration: max(r.Duration, time.Minute), + Opts: opts, + }) }) crashed := result != nil && result.Report != nil log.Logf(1, "attempt #%d to run %q on base: crashed=%v", i, ret.originalTitle, crashed) diff --git a/tools/syz-repro/repro.go b/tools/syz-repro/repro.go index 220170599..d47b75698 100644 --- a/tools/syz-repro/repro.go +++ b/tools/syz-repro/repro.go @@ -67,7 +67,12 @@ func main() { go func() { defer done() - res, stats, err := repro.Run(data, cfg, flatrpc.AllFeatures, reporter, pool) + res, stats, err := repro.Run(ctx, data, repro.Environment{ + Config: cfg, + Features: flatrpc.AllFeatures, + Reporter: reporter, + Pool: pool, + }) if err != nil { log.Logf(0, "reproduction failed: %v", err) } -- cgit mrf-deployment