]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[dev.fuzz] internal/fuzz: fix context cancellation for coordinator
authorKatie Hockman <katie@golang.org>
Wed, 13 Jan 2021 19:43:30 +0000 (14:43 -0500)
committerKatie Hockman <katie@golang.org>
Thu, 14 Jan 2021 14:40:52 +0000 (14:40 +0000)
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 <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/internal/fuzz/fuzz.go
src/internal/fuzz/worker.go
src/testing/internal/testdeps/deps.go

index 2a60e73c7fbcdbbcc928d7a2a79affa18d878b19..e05b5566ae6478b3f43a79de29412e21e965e1f6 100644 (file)
@@ -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
                                }
                        }
                }
index 89476419968512bb408b5dcf241a035e2b3d935c..ee31ff43c6c27e9e16c859ab02a30a48e121fd5c 100644 (file)
@@ -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}
                                        }
index 12da4f3863530a8a36708219e197c687f80370d5..dbc30ddc0fe211f7cb1de68edec0cc75656cdd40 100644 (file)
@@ -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)
        }