aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing.go
diff options
context:
space:
mode:
authorJay Conrod <jayconrod@google.com>2021-06-21 15:22:32 -0700
committerJay Conrod <jayconrod@google.com>2021-06-23 16:05:25 +0000
commit3fa42437b5d6326aa1ae04726ad4319459280433 (patch)
tree2f0e44a6ad49517592f1c0418b3ff8dae243b072 /src/testing/testing.go
parentff6f2051d9151a03d012c3020c62f3574e1b2d1b (diff)
downloadgo-3fa42437b5d6326aa1ae04726ad4319459280433.tar.xz
[dev.fuzz] internal/fuzz: fix race in worker RPC logic
We want worker RPCs to return as soon as the context is cancelled, which happens if the user presses ^C, we hit the time limit, or another worker discovers a crasher. RPCs typically block when reading pipes: the server waits for call arguments from the client, and the client waits for results from the server. Since io.Reader.Read doesn't accept a context.Context and reads on pipe file descriptors are difficult to reliably unblock, we've done this by calling Read in a goroutine, and returning from the parent function when ctx.Done() is closed, even if the underlying goroutine isn't finished. In workerServer.serve, we also called the fuzz function in the same goroutine. This resulted in a bug: serve could return while the fuzz function was still running. The fuzz function could observe side effects from cleanup functions registered with F.Cleanup. This change refactors read cancellation logic into contextReader. Only the underlying Read is done in a goroutine. workerServe.serve won't return while the fuzz function is running. Fixes #46632 Change-Id: Id1ed31f6521155c7c8e76dd52a2d70aa93cab201 Reviewed-on: https://go-review.googlesource.com/c/go/+/329920 Trust: Jay Conrod <jayconrod@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>
Diffstat (limited to 'src/testing/testing.go')
0 files changed, 0 insertions, 0 deletions