golang/go · error
preprocessed profile entry missing callee
Error message
preprocessed profile entry missing callee
What it means
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.
Source
Thrown at src/cmd/internal/pgo/deserialize.go:57
if err := scanner.Err(); err != nil {
return nil, fmt.Errorf("error reading preprocessed profile: %w", err)
}
return nil, fmt.Errorf("preprocessed profile missing header")
}
if gotHdr := scanner.Text() + "\n"; gotHdr != serializationHeader {
return nil, fmt.Errorf("preprocessed profile malformed header; got %q want %q", gotHdr, serializationHeader)
}
for scanner.Scan() {
readStr := scanner.Text()
callerName := readStr
if !scanner.Scan() {
if err := scanner.Err(); err != nil {
return nil, fmt.Errorf("error reading preprocessed profile: %w", err)
}
return nil, fmt.Errorf("preprocessed profile entry missing callee")
}
calleeName := scanner.Text()
if !scanner.Scan() {
if err := scanner.Err(); err != nil {
return nil, fmt.Errorf("error reading preprocessed profile: %w", err)
}
return nil, fmt.Errorf("preprocessed profile entry missing weight")
}
readStr = scanner.Text()
split := strings.Split(readStr, " ")
if len(split) != 2 {
return nil, fmt.Errorf("preprocessed profile entry got %v want 2 fields", split)
}
co, err := strconv.Atoi(split[0])View on GitHub (pinned to b6b368adc5)
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.
Defensive patterns
Strategy: validation
Validate before calling
// Sanity-check that the profile has a multiple-of-three record body.
// lines := strings.Split(strings.TrimSpace(string(data)), "\n")
// if (len(lines)-1)%3 != 0 { return errors.New("profile record count not a multiple of 3") } Try / catch
// prof, err := pgo.FromSerialized(r)
// if err != nil {
// if err.Error() == "preprocessed profile entry missing callee" ||
// err.Error() == "preprocessed profile entry missing weight" {
// // truncated record; regenerate the profile
// }
// return err
// } Prevention
- 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.
When it happens
Trigger: An odd number of remaining lines (a caller with no callee) due to the file being truncated mid-record.
Common situations: A profile file that was cut off while being written (disk full, process killed), leaving a dangling caller line.
Related errors
- error reading profile header: %w
- error reading preprocessed profile: %w
- preprocessed profile missing header
- preprocessed profile malformed header; got %q want %q
- error opening target for caching: %w
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/6713efd4fbe32068.
Report an issue: GitHub.