From 73a168d010b3ba0a82f850b9fe73e6907539ff20 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 23 Apr 2025 12:32:03 +0200 Subject: vm/dispatcher: make pool.Run cancellable Make the pool.Run() function take a context.Context to be able to abort the callback passed to it or abort its scheduling if it's not yet running. Otherwise, if the callback is not yet started and the pool's Loop is aborted, we risk waiting for pool.Run() forever. It prevents the normal shutdown of repro.Run() and, consequently, the DiffFuzzer functionality. --- pkg/manager/diff.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pkg/manager/diff.go') diff --git a/pkg/manager/diff.go b/pkg/manager/diff.go index 379fd246c..d7860cc9a 100644 --- a/pkg/manager/diff.go +++ b/pkg/manager/diff.go @@ -6,6 +6,7 @@ package manager import ( "context" "encoding/json" + "errors" "fmt" "math/rand" "net" @@ -583,7 +584,7 @@ func (rr *reproRunner) Run(ctx context.Context, r *repro.Result) { // The third time we leave it as is in case it was important. opts.Threaded = true } - pool.Run(func(ctx context.Context, inst *vm.Instance, updInfo dispatcher.UpdateInfo) { + runErr := pool.Run(ctx, func(ctx context.Context, inst *vm.Instance, updInfo dispatcher.UpdateInfo) { var ret *instance.ExecProgInstance ret, err = instance.SetupExecProg(inst, rr.kernel.cfg, rr.kernel.reporter, nil) if err != nil { @@ -595,6 +596,9 @@ func (rr *reproRunner) Run(ctx context.Context, r *repro.Result) { Opts: opts, }) }) + if errors.Is(runErr, context.Canceled) { + break + } crashed := result != nil && result.Report != nil log.Logf(1, "attempt #%d to run %q on base: crashed=%v", i, ret.origReport.Title, crashed) if crashed { -- cgit mrf-deployment