Skip to content

testing: Fuzz testing with fuzztime flag sometimes fails incorrectly with "context deadline exceeded" [1.26 backport] #82362

Open

Description

@gopherbot

@tiberiupetrache requested issue #75804 to be considered for backport to the next 1.26 minor release.

@gopherbot please backport to Go 1.26

The fix (5a957dc, CL 774140) is on master and release-branch.go1.27 (CL 804900). release-branch.go1.26 still has the old condition in stop in CoordinateFuzzing:

if err == fuzzCtx.Err() || isInterruptError(err) {

On go1.26.9 (windows/amd64), a fuzz target that cannot fail, run 1200 times with -fuzztime=1s -parallel=8, failed 3 times, each with no failing input:

func FuzzNothing(f *testing.F) {
	f.Add([]byte("seed"))
	f.Fuzz(func(t *testing.T, b []byte) { _ = len(b) })
}
--- FAIL: FuzzNothing (1.17s)
    context deadline exceeded
FAIL

The same harness on go1.27.3 failed 0 times in 1200 runs. We also hit it in CI on go1.26.9 linux/amd64 with -fuzztime=60s.

The race can also hide a real crash. If it hits while a crasher is being minimized, the deferred writeToCorpus in CoordinateFuzzing still writes the input to testdata/fuzz, but it wraps the error in a crashError only when err == nil. Here the error stays context.DeadlineExceeded, so "Failing input written to ..." is never printed and the crash looks like a timeout flake. The fix closes this path too.

The fix changes one condition in stop. The workaround, -fuzztime=Nx, replaces the time budget with an execution count.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CherryPickApprovedUsed during the release process for point releases

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions