aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorJay Conrod <jayconrod@google.com>2021-01-15 14:43:25 -0500
committerJay Conrod <jayconrod@google.com>2021-01-15 23:24:58 +0000
commit8e0584c327e429bd010edb28fb9fea6f68a4cccc (patch)
treee878b6c005a43e118ba5d1e26c51f619587d51a1 /src/testing
parentd45df5de32e555a0386b7e473d30516d744df70a (diff)
downloadgo-8e0584c327e429bd010edb28fb9fea6f68a4cccc.tar.xz
[dev.fuzz] internal/fuzz: handle SIGINT races gracefully
A worker process may be terminated by SIGINT if it doesn't install the signal handler before SIGINT is delivered. That's likely when TestMain or the fuzz target setup take a long time. The coordinator now ignores these errors. Also, when testdeps.TestDeps.CoordinateFuzzing and RunFuzzWorker return, they will send a value on the chan passed to signal.Notify instead of closing it. This should have been obvious in hindsight, but the signal handler could still send a value on that channel after those functions return but before the process exits. Change-Id: Iea2589115f1f9bb7415bb5e7911defee423e642e Reviewed-on: https://go-review.googlesource.com/c/go/+/284292 Trust: Jay Conrod <jayconrod@google.com> Reviewed-by: Katie Hockman <katie@golang.org>
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/internal/testdeps/deps.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/testing/internal/testdeps/deps.go b/src/testing/internal/testdeps/deps.go
index dbc30ddc0f..2d0d7bac38 100644
--- a/src/testing/internal/testdeps/deps.go
+++ b/src/testing/internal/testdeps/deps.go
@@ -146,7 +146,7 @@ func (TestDeps) CoordinateFuzzing(timeout time.Duration, parallel int, seed [][]
<-interruptC
cancel()
}()
- defer close(interruptC)
+ defer func() { interruptC <- os.Interrupt }()
err := fuzz.CoordinateFuzzing(ctx, parallel, seed, corpusDir, cacheDir)
if err == ctx.Err() {
@@ -169,7 +169,7 @@ func (TestDeps) RunFuzzWorker(fn func([]byte) error) error {
<-interruptC
cancel()
}()
- defer close(interruptC)
+ defer func() { interruptC <- os.Interrupt }()
err := fuzz.RunFuzzWorker(ctx, fn)
if err == ctx.Err() {