golang/go · error

preprocessed profile error processing call weight: %w

Error message

preprocessed profile error processing call weight: %w

What it means

Thrown when strconv.ParseInt fails to parse the second field of the weight line (split[1]) as a 64-bit signed integer. This field represents the edge weight (sample count or CPU nanoseconds). The %w wraps the strconv error. ParseInt is called with base 10 and bitSize 64.

Source

Thrown at src/cmd/internal/pgo/deserialize.go:88

		if len(split) != 2 {
			return nil, fmt.Errorf("preprocessed profile entry got %v want 2 fields", split)
		}

		co, err := strconv.Atoi(split[0])
		if err != nil {
			return nil, fmt.Errorf("preprocessed profile error processing call line: %w", err)
		}

		edge := NamedCallEdge{
			CallerName:     callerName,
			CalleeName:     calleeName,
			CallSiteOffset: co,
		}

		weight, err := strconv.ParseInt(split[1], 10, 64)
		if err != nil {
			return nil, fmt.Errorf("preprocessed profile error processing call weight: %w", err)
		}

		if _, ok := d.NamedEdgeMap.Weight[edge]; ok {
			return nil, fmt.Errorf("preprocessed profile contains duplicate edge %+v", edge)
		}

		d.NamedEdgeMap.ByWeight = append(d.NamedEdgeMap.ByWeight, edge) // N.B. serialization is ordered.
		d.NamedEdgeMap.Weight[edge] += weight
		d.TotalWeight += weight
	}

	return d, nil

}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Regenerate the profile so weights are plain base-10 64-bit integers.
  2. If weights are very large, confirm they fit within int64 range (max ~9.2e18).
  3. Check that no decimal points, units, or scientific notation appear in the weight field.

Example fix

// Before (broken): "42 1.5e6"    (scientific notation)
// After (fixed):  "42 1500000"  (plain integer)
Defensive patterns

Strategy: validation

Validate before calling

// Validate that the weight field is a valid int64:
func validateWeights(path string) error {
    data, err := os.ReadFile(path)
    if err != nil { return err }
    lines := strings.Split(strings.TrimRight(string(data), "\n"), "\n")
    for i := 2; i < len(lines); i += 3 {
        fields := strings.Split(lines[i], " ")
        if _, err := strconv.ParseInt(fields[1], 10, 64); err != nil {
            return fmt.Errorf("line %d: invalid weight %q: %w", i+1, fields[1], err)
        }
    }
    return nil
}

Prevention

When it happens

Trigger: split[1] is not a valid base-10 signed 64-bit integer. This could be a non-numeric string, an empty string, a floating-point representation, or a value that overflows int64.

Common situations: Profile serialized with floating-point or scientific-notation weights (e.g. "1.5e6"), weights exceeding int64 range, or a format mismatch where the weight field contains a unit suffix or other annotation.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/6e2c668e3cf167f9. Report an issue: GitHub.