{"record":{"id":"6713efd4fbe32068","repo":"golang/go","slug":"preprocessed-profile-entry-missing-callee","errorCode":null,"errorMessage":"preprocessed profile entry missing callee","messagePattern":"preprocessed profile entry missing callee","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/pgo/deserialize.go","lineNumber":57,"sourceCode":"\t\tif err := scanner.Err(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error reading preprocessed profile: %w\", err)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"preprocessed profile missing header\")\n\t}\n\tif gotHdr := scanner.Text() + \"\\n\"; gotHdr != serializationHeader {\n\t\treturn nil, fmt.Errorf(\"preprocessed profile malformed header; got %q want %q\", gotHdr, serializationHeader)\n\t}\n\n\tfor scanner.Scan() {\n\t\treadStr := scanner.Text()\n\n\t\tcallerName := readStr\n\n\t\tif !scanner.Scan() {\n\t\t\tif err := scanner.Err(); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error reading preprocessed profile: %w\", err)\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"preprocessed profile entry missing callee\")\n\t\t}\n\t\tcalleeName := scanner.Text()\n\n\t\tif !scanner.Scan() {\n\t\t\tif err := scanner.Err(); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error reading preprocessed profile: %w\", err)\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"preprocessed profile entry missing weight\")\n\t\t}\n\t\treadStr = scanner.Text()\n\n\t\tsplit := strings.Split(readStr, \" \")\n\n\t\tif len(split) != 2 {\n\t\t\treturn nil, fmt.Errorf(\"preprocessed profile entry got %v want 2 fields\", split)\n\t\t}\n\n\t\tco, err := strconv.Atoi(split[0])","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/pgo/deserialize.go#L39-L75","documentation":"A serialized PGO profile is a sequence of caller/callee/weight line triplets. After reading a caller line, the next Scan returned false with no error — meaning the file ended before the callee line was present. The record is therefore incomplete.","triggerScenarios":"An odd number of remaining lines (a caller with no callee) due to the file being truncated mid-record.","commonSituations":"A profile file that was cut off while being written (disk full, process killed), leaving a dangling caller line.","solutions":["Regenerate the profile cleanly with Profile.WriteTo.","Ensure the writing process completes and the file is flushed/closed.","Validate with IsSerialized and check the file size before parsing."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Sanity-check that the profile has a multiple-of-three record body.\n// lines := strings.Split(strings.TrimSpace(string(data)), \"\\n\")\n// if (len(lines)-1)%3 != 0 { return errors.New(\"profile record count not a multiple of 3\") }","typeGuard":null,"tryCatchPattern":"// prof, err := pgo.FromSerialized(r)\n// if err != nil {\n//     if err.Error() == \"preprocessed profile entry missing callee\" ||\n//        err.Error() == \"preprocessed profile entry missing weight\" {\n//         // truncated record; regenerate the profile\n//     }\n//     return err\n// }","preventionTips":["Regenerate the profile if the writer was killed mid-flush.","Ensure the profile is fully written and closed before use.","Validate record structure before handing the file to FromSerialized."],"tags":["pgo","profile","truncated","deserialize"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}