{"record":{"id":"f1693ed6e6d36118","repo":"golang/go","slug":"failed-to-parse-any-useful-part-of-the-trace-v","errorCode":null,"errorMessage":"failed to parse any useful part of the trace: %v","messagePattern":"failed to parse any useful part of the trace: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/trace/main.go","lineNumber":383,"sourceCode":"\t\t\tvalidEvents = len(t.events)\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\tt.err = err\n\t\t\tbreak\n\t\t}\n\t\tt.events = append(t.events, ev)\n\t\ts.Event(&t.events[len(t.events)-1])\n\n\t\tif ev.Kind() == trace.EventSync {\n\t\t\tvalidBytes = cr.bytesRead.Load()\n\t\t\tvalidEvents = len(t.events)\n\t\t}\n\t}\n\n\t// Check to make sure we got at least one good generation.\n\tif validEvents == 0 {\n\t\treturn nil, fmt.Errorf(\"failed to parse any useful part of the trace: %v\", t.err)\n\t}\n\n\t// Finish off the parsedTrace.\n\tt.summary = s.Finalize()\n\tt.valid = validBytes\n\tt.size = size\n\tt.events = t.events[:validEvents]\n\treturn t, nil\n}\n\nfunc (t *parsedTrace) startTime() trace.Time {\n\treturn t.events[0].Time()\n}\n\nfunc (t *parsedTrace) endTime() trace.Time {\n\treturn t.events[len(t.events)-1].Time()\n}\n","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/trace/main.go#L365-L401","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// re-record on parse failure\nif _, err := parseTrace(f, sz); err != nil {\n    log.Printf(\"trace unusable (%v); re-recording\", err)\n    rerecord()\n}","preventionTips":["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."],"tags":["go-tool-trace","trace","data-corruption","truncated-file"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}