Skip to content

[dev.fuzz] cmd/go: fuzzing can sometimes print both "PASS" and "FAIL" #46969

Closed
@katiehockman

Description

@katiehockman

I was playing around with the fuzz target in #46632, and noticed a bug.

~ go test internal/fuzz -v -run=None -fuzz=FuzzCleanup
=== FUZZ  FuzzCleanup
fuzzing, elapsed: 3.0s, execs: 8 (3/sec), workers: 8, interesting: 1
fuzzing, elapsed: 6.0s, execs: 32 (5/sec), workers: 8, interesting: 1
<pressed Ctrl+C>
--- PASS: FuzzCleanup (7.08s)
PASS
ok      internal/fuzz   7.238s
FAIL

Note that the go command says that FuzzCleanup passed, but the last line says FAIL. I'm guessing there's a race or something going on, since this only happens occasionally, and I haven't figured out how to reproduce this consistently.

This was the target I used (from #46632):

func FuzzCleanup(f *testing.F) {
	var mu sync.Mutex
	var cleaned bool
	f.Cleanup(func() {
		mu.Lock()
		cleaned = true
		mu.Unlock()
	})
	f.Add([]byte("abc"))
	f.Fuzz(func(t *testing.T, data []byte) {
		time.Sleep(time.Second)
		mu.Lock()
		defer mu.Unlock()
		if cleaned {
			panic("Cleanup called before fuzzing finished.")
		}
	})
}

/cc @golang/fuzzing

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.fuzzIssues related to native fuzzing supportrelease-blocker

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions