mirror of
https://github.com/golang/go
synced 2024-09-29 23:14:29 -06:00
internal/fuzz: improve debugging messages
Also enable debugging information in TestScript/test_fuzz_cov, which hits a deadlock on builders, but I am unable to trigger locally. This should make it somewhat easier to track down where the issue actually is. Updates #51484 Change-Id: I98124f862242798f2d9eba15cacefbd02924cfe2 Reviewed-on: https://go-review.googlesource.com/c/go/+/476595 Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
2d84fbbad8
commit
70308d1375
5
src/cmd/go/testdata/script/test_fuzz_cov.txt
vendored
5
src/cmd/go/testdata/script/test_fuzz_cov.txt
vendored
@ -5,7 +5,10 @@
|
|||||||
[short] skip
|
[short] skip
|
||||||
[!fuzz-instrumented] skip
|
[!fuzz-instrumented] skip
|
||||||
|
|
||||||
! go test -fuzz=FuzzCov
|
# TODO(#51484): enabled debugging info to help diagnose a deadlock in the fuzzer
|
||||||
|
env GODEBUG=fuzzdebug=1
|
||||||
|
go clean --fuzzcache
|
||||||
|
! go test -fuzz=FuzzCov -v
|
||||||
! stderr 'cov instrumentation working'
|
! stderr 'cov instrumentation working'
|
||||||
|
|
||||||
-- go.mod --
|
-- go.mod --
|
||||||
|
@ -117,6 +117,15 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err
|
|||||||
var fuzzErr error
|
var fuzzErr error
|
||||||
stopping := false
|
stopping := false
|
||||||
stop := func(err error) {
|
stop := func(err error) {
|
||||||
|
if shouldPrintDebugInfo() {
|
||||||
|
_, file, line, ok := runtime.Caller(1)
|
||||||
|
if ok {
|
||||||
|
c.debugLogf("stop called at %s:%d. stopping: %t", file, line, stopping)
|
||||||
|
} else {
|
||||||
|
c.debugLogf("stop called at unknown. stopping: %t", stopping)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err == fuzzCtx.Err() || isInterruptError(err) {
|
if err == fuzzCtx.Err() || isInterruptError(err) {
|
||||||
// Suppress cancellation errors and terminations due to SIGINT.
|
// Suppress cancellation errors and terminations due to SIGINT.
|
||||||
// The messages are not helpful since either the user triggered the error
|
// The messages are not helpful since either the user triggered the error
|
||||||
@ -244,6 +253,9 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err
|
|||||||
if c.crashMinimizing != nil {
|
if c.crashMinimizing != nil {
|
||||||
// This crash is not minimized, and another crash is being minimized.
|
// This crash is not minimized, and another crash is being minimized.
|
||||||
// Ignore this one and wait for the other one to finish.
|
// Ignore this one and wait for the other one to finish.
|
||||||
|
if shouldPrintDebugInfo() {
|
||||||
|
c.debugLogf("found unminimized crasher, skipping in favor of minimizable crasher")
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// Found a crasher but haven't yet attempted to minimize it.
|
// Found a crasher but haven't yet attempted to minimize it.
|
||||||
@ -264,10 +276,8 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if shouldPrintDebugInfo() {
|
if shouldPrintDebugInfo() {
|
||||||
fmt.Fprintf(
|
c.debugLogf(
|
||||||
c.opts.Log,
|
"found crasher, id: %s, parent: %s, gen: %d, size: %d, exec time: %s",
|
||||||
"DEBUG new crasher, elapsed: %s, id: %s, parent: %s, gen: %d, size: %d, exec time: %s\n",
|
|
||||||
c.elapsed(),
|
|
||||||
result.entry.Path,
|
result.entry.Path,
|
||||||
result.entry.Parent,
|
result.entry.Parent,
|
||||||
result.entry.Generation,
|
result.entry.Generation,
|
||||||
@ -280,10 +290,8 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err
|
|||||||
} else if result.coverageData != nil {
|
} else if result.coverageData != nil {
|
||||||
if c.warmupRun() {
|
if c.warmupRun() {
|
||||||
if shouldPrintDebugInfo() {
|
if shouldPrintDebugInfo() {
|
||||||
fmt.Fprintf(
|
c.debugLogf(
|
||||||
c.opts.Log,
|
"processed an initial input, id: %s, new bits: %d, size: %d, exec time: %s",
|
||||||
"DEBUG processed an initial input, elapsed: %s, id: %s, new bits: %d, size: %d, exec time: %s\n",
|
|
||||||
c.elapsed(),
|
|
||||||
result.entry.Parent,
|
result.entry.Parent,
|
||||||
countBits(diffCoverage(c.coverageMask, result.coverageData)),
|
countBits(diffCoverage(c.coverageMask, result.coverageData)),
|
||||||
len(result.entry.Data),
|
len(result.entry.Data),
|
||||||
@ -295,10 +303,8 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err
|
|||||||
if c.warmupInputLeft == 0 {
|
if c.warmupInputLeft == 0 {
|
||||||
fmt.Fprintf(c.opts.Log, "fuzz: elapsed: %s, gathering baseline coverage: %d/%d completed, now fuzzing with %d workers\n", c.elapsed(), c.warmupInputCount, c.warmupInputCount, c.opts.Parallel)
|
fmt.Fprintf(c.opts.Log, "fuzz: elapsed: %s, gathering baseline coverage: %d/%d completed, now fuzzing with %d workers\n", c.elapsed(), c.warmupInputCount, c.warmupInputCount, c.opts.Parallel)
|
||||||
if shouldPrintDebugInfo() {
|
if shouldPrintDebugInfo() {
|
||||||
fmt.Fprintf(
|
c.debugLogf(
|
||||||
c.opts.Log,
|
"finished processing input corpus, entries: %d, initial coverage bits: %d",
|
||||||
"DEBUG finished processing input corpus, elapsed: %s, entries: %d, initial coverage bits: %d\n",
|
|
||||||
c.elapsed(),
|
|
||||||
len(c.corpus.entries),
|
len(c.corpus.entries),
|
||||||
countBits(c.coverageMask),
|
countBits(c.coverageMask),
|
||||||
)
|
)
|
||||||
@ -327,16 +333,20 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if !entryNew {
|
if !entryNew {
|
||||||
continue
|
if shouldPrintDebugInfo() {
|
||||||
|
c.debugLogf(
|
||||||
|
"ignoring duplicate input which increased coverage, id: %s",
|
||||||
|
result.entry.Path,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
c.updateCoverage(keepCoverage)
|
c.updateCoverage(keepCoverage)
|
||||||
c.inputQueue.enqueue(result.entry)
|
c.inputQueue.enqueue(result.entry)
|
||||||
c.interestingCount++
|
c.interestingCount++
|
||||||
if shouldPrintDebugInfo() {
|
if shouldPrintDebugInfo() {
|
||||||
fmt.Fprintf(
|
c.debugLogf(
|
||||||
c.opts.Log,
|
"new interesting input, id: %s, parent: %s, gen: %d, new bits: %d, total bits: %d, size: %d, exec time: %s",
|
||||||
"DEBUG new interesting input, elapsed: %s, id: %s, parent: %s, gen: %d, new bits: %d, total bits: %d, size: %d, exec time: %s\n",
|
|
||||||
c.elapsed(),
|
|
||||||
result.entry.Path,
|
result.entry.Path,
|
||||||
result.entry.Parent,
|
result.entry.Parent,
|
||||||
result.entry.Generation,
|
result.entry.Generation,
|
||||||
@ -349,10 +359,8 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if shouldPrintDebugInfo() {
|
if shouldPrintDebugInfo() {
|
||||||
fmt.Fprintf(
|
c.debugLogf(
|
||||||
c.opts.Log,
|
"worker reported interesting input that doesn't expand coverage, id: %s, parent: %s, canMinimize: %t",
|
||||||
"DEBUG worker reported interesting input that doesn't expand coverage, elapsed: %s, id: %s, parent: %s, canMinimize: %t\n",
|
|
||||||
c.elapsed(),
|
|
||||||
result.entry.Path,
|
result.entry.Path,
|
||||||
result.entry.Parent,
|
result.entry.Parent,
|
||||||
result.canMinimize,
|
result.canMinimize,
|
||||||
@ -366,10 +374,8 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err
|
|||||||
if c.warmupInputLeft == 0 {
|
if c.warmupInputLeft == 0 {
|
||||||
fmt.Fprintf(c.opts.Log, "fuzz: elapsed: %s, testing seed corpus: %d/%d completed, now fuzzing with %d workers\n", c.elapsed(), c.warmupInputCount, c.warmupInputCount, c.opts.Parallel)
|
fmt.Fprintf(c.opts.Log, "fuzz: elapsed: %s, testing seed corpus: %d/%d completed, now fuzzing with %d workers\n", c.elapsed(), c.warmupInputCount, c.warmupInputCount, c.opts.Parallel)
|
||||||
if shouldPrintDebugInfo() {
|
if shouldPrintDebugInfo() {
|
||||||
fmt.Fprintf(
|
c.debugLogf(
|
||||||
c.opts.Log,
|
"finished testing-only phase, entries: %d",
|
||||||
"DEBUG finished testing-only phase, elapsed: %s, entries: %d\n",
|
|
||||||
time.Since(c.startTime),
|
|
||||||
len(c.corpus.entries),
|
len(c.corpus.entries),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -814,6 +820,13 @@ func (c *coordinator) refillInputQueue() {
|
|||||||
// queueForMinimization creates a fuzzMinimizeInput from result and adds it
|
// queueForMinimization creates a fuzzMinimizeInput from result and adds it
|
||||||
// to the minimization queue to be sent to workers.
|
// to the minimization queue to be sent to workers.
|
||||||
func (c *coordinator) queueForMinimization(result fuzzResult, keepCoverage []byte) {
|
func (c *coordinator) queueForMinimization(result fuzzResult, keepCoverage []byte) {
|
||||||
|
if shouldPrintDebugInfo() {
|
||||||
|
c.debugLogf(
|
||||||
|
"queueing input for minimization, id: %s, crasher: %t",
|
||||||
|
result.entry.Path,
|
||||||
|
result.crasherMsg != "",
|
||||||
|
)
|
||||||
|
}
|
||||||
if result.crasherMsg != "" {
|
if result.crasherMsg != "" {
|
||||||
c.minimizeQueue.clear()
|
c.minimizeQueue.clear()
|
||||||
}
|
}
|
||||||
@ -1081,3 +1094,8 @@ var debugInfo = godebug.New("fuzzdebug").Value() == "1"
|
|||||||
func shouldPrintDebugInfo() bool {
|
func shouldPrintDebugInfo() bool {
|
||||||
return debugInfo
|
return debugInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *coordinator) debugLogf(format string, args ...any) {
|
||||||
|
t := time.Now().Format("2006-01-02 15:04:05.999999999")
|
||||||
|
fmt.Fprintf(c.opts.Log, t+" DEBUG "+format+"\n", args...)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user