Skip to content

[dev.fuzz] skip running seed corpus as ordinary test when fuzzing the target #48296

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

Closed
katiehockman opened this issue Sep 9, 2021 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@katiehockman
Copy link
Contributor

Related to #46222

From @rsc: "check whether a fuzz test matches the -fuzz pattern and if so not run just that one test function as an ordinary test case, because that duplicates work and also because the fuzzing harness can do a better job with infinite loops."

We already have to run all of the seed corpus anyway when -fuzz is set in order to get baseline coverage data. The only time we don't is if instrumentation wasn't done (e.g. someone manually built the test with go test -c). We could refactor the code to make sure the coordinator always has the workers run this seed corpus and correctly report any failing seed corpus in this setup step.

This won't actually change the underlying UX of fuzzing, other than to have fewer lines printed if run with -v since each seed corpus will no longer be run as an individual test.

@katiehockman katiehockman added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 9, 2021
@katiehockman katiehockman added this to the Backlog milestone Sep 9, 2021
@katiehockman katiehockman self-assigned this Sep 13, 2021
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/349630 mentions this issue: [dev.fuzz] internal/fuzz: rework default test behavior before fuzzing

gopherbot pushed a commit that referenced this issue Sep 16, 2021
This change refactors some of the code to support skipping a run
of the seed corpus by the go command before runFuzzing occurs.
Previously, the go command would run all seed corpus for all targets
that match the provided `run` argument. This will be redundant when
fuzzing a target. Now, the seed corpus is only run by targets other than
the one that's about to be fuzzed, and the worker handles running and
reporting issues with the seed corpus.

Part of the logic that needed close inspection is what to do if a
failure occurs during a testing-only or coverage-only fail. If the input
is already in the seed corpus, the fuzzing engine shouldn't add it. If
the input is currently in the cache, then it should be written to
testdata. In all cases, if an error occurs, we need to report this to
the user with enough information for them to debug it.

This uncovered some issues with our code when fuzzing without
instrumentation, and when -run=None was provided. There are some logic
fixes in this change, and some small refactors.

Fixes #48327
Fixes #48296

Change-Id: I9ce2be0219c5b09277ddd308df8bc5a46d4558fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/349630
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>
@dmitshur dmitshur modified the milestones: Backlog, go1.18, Go1.18 Jul 6, 2022
@golang golang locked and limited conversation to collaborators Jul 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants