-
Notifications
You must be signed in to change notification settings - Fork 18k
[dev.fuzz] testing: f.Cleanup called before fuzzing is done. #46632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
/cc @jayconrod |
This looks like a bug. I couldn't reproduce it at all on macOS, but I think I know why it's happening. There are a couple places in In one of these places, we call the fuzz function after the read completes successfully. If the context is cancelled while the fuzz function is running, we might start cleaning up while the fuzz function continues to run. |
Change https://golang.org/cl/329920 mentions this issue: |
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 <[email protected]> Trust: Katie Hockman <[email protected]> Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Katie Hockman <[email protected]>
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run fuzzer:
What did you expect to see?
f.Cleanup()
is called when all fuzzers have finished, giving no output.I think this is a reasonable expectation. Otherwise the usefulness is pretty reduced of
f.Cleanup
, or at least annoying to use, having to add async.Waitgroup
.What did you see instead?
Output: https://gist.github.com/klauspost/fcbfa313d9dfab5b927fb7b80ad75775
The text was updated successfully, but these errors were encountered: