From: Katie Hockman Date: Wed, 13 Jan 2021 19:43:30 +0000 (-0500) Subject: [dev.fuzz] internal/fuzz: fix context cancellation for coordinator X-Git-Tag: go1.18beta1~1282^2~107 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=06074108fab489d6bd7358e736bcd0cb38830c7c;p=gostls13.git [dev.fuzz] internal/fuzz: fix context cancellation for coordinator Previously, performing a SIGINT would cause the coordinator to write a crash to testdata, and would continue to run despite being interupted. Also includes a few small cleanups. Change-Id: Ia3cf7cd231c30ac9ad2a61f4935aa543e241f60d Reviewed-on: https://go-review.googlesource.com/c/go/+/283634 Trust: Katie Hockman Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Jay Conrod --- diff --git a/src/internal/fuzz/fuzz.go b/src/internal/fuzz/fuzz.go index 2a60e73c7f..e05b5566ae 100644 --- a/src/internal/fuzz/fuzz.go +++ b/src/internal/fuzz/fuzz.go @@ -119,6 +119,7 @@ func CoordinateFuzzing(ctx context.Context, parallel int, seed [][]byte, corpusD // Return the first error found, replacing ctx.Err() if a more // interesting error is found. err = werr + break } } } diff --git a/src/internal/fuzz/worker.go b/src/internal/fuzz/worker.go index 8947641996..ee31ff43c6 100644 --- a/src/internal/fuzz/worker.go +++ b/src/internal/fuzz/worker.go @@ -135,7 +135,7 @@ func (w *worker) runFuzzing() error { w.coordinator.crasherC <- crasher } else { // Inform the coordinator that fuzzing found something - // interesting (ie. a crash or new coverage). + // interesting (i.e. new coverage). if resp.Interesting { w.coordinator.interestingC <- corpusEntry{b: value} } diff --git a/src/testing/internal/testdeps/deps.go b/src/testing/internal/testdeps/deps.go index 12da4f3863..dbc30ddc0f 100644 --- a/src/testing/internal/testdeps/deps.go +++ b/src/testing/internal/testdeps/deps.go @@ -136,8 +136,7 @@ func (TestDeps) CoordinateFuzzing(timeout time.Duration, parallel int, seed [][] // Fuzzing may be interrupted with a timeout or if the user presses ^C. // In either case, we'll stop worker processes gracefully and save // crashers and interesting values. - ctx := context.Background() - cancel := func() {} + ctx, cancel := context.WithCancel(context.Background()) if timeout > 0 { ctx, cancel = context.WithTimeout(ctx, timeout) }