golang/go · error
failed to parse any useful part of the trace: %v
Error message
failed to parse any useful part of the trace: %v
What it means
After the reader is created, `parseTrace` reads events until EOF, tracking `validEvents` — the count of events seen up to the last `EventSync`. If no sync point was ever reached (zero useful events), the trace is considered too corrupt/truncated to display and the accumulated per-event error `t.err` is surfaced. The viewer refuses to open rather than show misleading partial data.
Source
Thrown at src/cmd/trace/main.go:383
validEvents = len(t.events)
break
}
if err != nil {
t.err = err
break
}
t.events = append(t.events, ev)
s.Event(&t.events[len(t.events)-1])
if ev.Kind() == trace.EventSync {
validBytes = cr.bytesRead.Load()
validEvents = len(t.events)
}
}
// Check to make sure we got at least one good generation.
if validEvents == 0 {
return nil, fmt.Errorf("failed to parse any useful part of the trace: %v", t.err)
}
// Finish off the parsedTrace.
t.summary = s.Finalize()
t.valid = validBytes
t.size = size
t.events = t.events[:validEvents]
return t, nil
}
func (t *parsedTrace) startTime() trace.Time {
return t.events[0].Time()
}
func (t *parsedTrace) endTime() trace.Time {
return t.events[len(t.events)-1].Time()
}
View on GitHub (pinned to b6b368adc5)
Solutions
- Re-record the trace ensuring the program reaches a clean `runtime/trace.Stop` (or defer it in main).
- Check the program did not crash/OOM during tracing; capture to a local file rather than a pipe/network sink.
- Ensure there is free disk space for the full trace write.
- If you have a partial trace you genuinely want to inspect, try `-d=wire` to dump raw events directly, bypassing the sync requirement.
Defensive patterns
Strategy: try-catch
Try / catch
// re-record on parse failure
if _, err := parseTrace(f, sz); err != nil {
log.Printf("trace unusable (%v); re-recording", err)
rerecord()
} Prevention
- Always defer runtime/trace.Stop so the trace flushes a full generation.
- Write traces to a local file, not over a network/pipe that can break.
When it happens
Trigger: A trace whose generation(s) all failed to parse before the first sync; a file truncated mid-generation before any generation closed; a trace from a crashing program that never flushed a complete generation; mixing bytes from two traces.
Common situations: Program crashed mid-trace before `trace.Stop` flushed; trace captured over a pipe that broke early; disk-full during trace write; trace concatenation experiments producing a non-sync-prefixable stream.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to create trace reader: %w
- no trace file supplied
- failed to read trace file: %w
- failed to stat trace file: %v
- unknown pprof type %s
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/f1693ed6e6d36118.
Report an issue: GitHub.