aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorKatie Hockman <katie@golang.org>2021-12-22 10:34:55 -0500
committerKatie Hockman <katie@golang.org>2022-01-06 22:12:11 +0000
commitb9cae6f78f129bb3f1b3293da5375040f5c4f356 (patch)
treec12964f62c18faa2b375a6f3831cdbf1c79534c4 /src/testing
parent61014f00f24df8b144d9d235fe3e25ff64b96521 (diff)
downloadgo-b9cae6f78f129bb3f1b3293da5375040f5c4f356.tar.gz
go-b9cae6f78f129bb3f1b3293da5375040f5c4f356.zip
testing: fix deadlock with t.Parallel in testing seed corpus
The c.startParallel channel on the testContext is stuck in t.Parallel() because c.running starts at 1 for the main fuzz parent test, and is causing a deadlock because it is never released. It would normally be released by tRunner, but needs to instead be released by fRunner instead for fuzz tests. Fixes #50217 Change-Id: I2d010e9adddfd8e8321ff2f9dd2e43daf46c128f Reviewed-on: https://go-review.googlesource.com/c/go/+/374054 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/fuzz.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/testing/fuzz.go b/src/testing/fuzz.go
index efb59b3e57..037d531acf 100644
--- a/src/testing/fuzz.go
+++ b/src/testing/fuzz.go
@@ -323,10 +323,10 @@ func (f *F) Fuzz(ff any) {
for _, v := range e.Values {
args = append(args, reflect.ValueOf(v))
}
- // Before reseting the current coverage, defer the snapshot so that we
- // make sure it is called right before the tRunner function exits,
- // regardless of whether it was executed cleanly, panicked, or if the
- // fuzzFn called t.Fatal.
+ // Before resetting the current coverage, defer the snapshot so that
+ // we make sure it is called right before the tRunner function
+ // exits, regardless of whether it was executed cleanly, panicked,
+ // or if the fuzzFn called t.Fatal.
defer f.fuzzContext.deps.SnapshotCoverage()
f.fuzzContext.deps.ResetCoverage()
fn.Call(args)
@@ -666,6 +666,7 @@ func fRunner(f *F, fn func(*F)) {
// This only affects fuzz tests run as normal tests.
// While fuzzing, T.Parallel has no effect, so f.sub is empty, and this
// branch is not taken. f.barrier is nil in that case.
+ f.testContext.release()
close(f.barrier)
// Wait for the subtests to complete.
for _, sub := range f.sub {