aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-04-24 12:05:06 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-04-24 14:15:38 +0000
commite3715315e5d4f79101d4cd782877608675dff0df (patch)
treee1d1228430f9baa3cdc5283e8208776fe1eb2cac /pkg
parente48b08e56fc5b9b57e6b04813946e3f53de8e4b6 (diff)
pkg/manager: wrap channel writes in select
Writes to channels are dangerous in the presence of context cancellation - no one may be listening on the receiving side. Wrap the writes in a select that also awaits ctx.Done().
Diffstat (limited to 'pkg')
-rw-r--r--pkg/manager/diff.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/pkg/manager/diff.go b/pkg/manager/diff.go
index 0ca4e3206..8f367b1e8 100644
--- a/pkg/manager/diff.go
+++ b/pkg/manager/diff.go
@@ -297,7 +297,11 @@ func (dc *diffContext) RunRepro(ctx context.Context, crash *Crash) *ReproResult
Stats: stats,
Err: err,
}
- dc.doneRepro <- ret
+ select {
+ case dc.doneRepro <- ret:
+ case <-ctx.Done():
+ // If the context is cancelled, no one may be listening on doneRepro.
+ }
return ret
}
@@ -506,7 +510,10 @@ func (kc *kernelContext) fuzzerInstance(ctx context.Context, inst *vm.Instance,
lastExec, _ := kc.serv.ShutdownInstance(index, rep != nil)
if rep != nil {
rpcserver.PrependExecuting(rep, lastExec)
- kc.crashes <- rep
+ select {
+ case kc.crashes <- rep:
+ case <-ctx.Done():
+ }
}
if err != nil {
log.Errorf("#%d run failed: %s", inst.Index(), err)