{"record":{"id":"ea5b4b72c1e30a17","repo":"golang/go","slug":"error-processing-serialized-pgo-profile-w","errorCode":null,"errorMessage":"error processing serialized PGO profile: %w","messagePattern":"error processing serialized PGO profile: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/compile/internal/pgoir/irgraph.go","lineNumber":139,"sourceCode":"// New generates a profile-graph from the profile or pre-processed profile.\nfunc New(profileFile string) (*Profile, error) {\n\tf, err := os.Open(profileFile)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error opening profile: %w\", err)\n\t}\n\tdefer f.Close()\n\tr := bufio.NewReader(f)\n\n\tisSerialized, err := pgo.IsSerialized(r)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error processing profile header: %w\", err)\n\t}\n\n\tvar base *pgo.Profile\n\tif isSerialized {\n\t\tbase, err = pgo.FromSerialized(r)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error processing serialized PGO profile: %w\", err)\n\t\t}\n\t} else {\n\t\tbase, err = pgo.FromPProf(r)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error processing pprof PGO profile: %w\", err)\n\t\t}\n\t}\n\n\tif base.TotalWeight == 0 {\n\t\treturn nil, nil // accept but ignore profile with no samples.\n\t}\n\n\t// Create package-level call graph with weights from profile and IR.\n\twg := createIRGraph(base.NamedEdgeMap)\n\n\treturn &Profile{\n\t\tProfile:    base,\n\t\tWeightedCG: wg,","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/compile/internal/pgoir/irgraph.go#L121-L157","documentation":"When pgo.IsSerialized detects the profile is in Go's serialized format, the compiler calls pgo.FromSerialized to deserialize it. This error wraps any deserialization failure, indicating the serialized data after the header is corrupt, truncated, or incompatible with the current compiler's expected format.","triggerScenarios":"A file with the correct serialized-format magic header but containing corrupted or incomplete data after the header. A serialized profile generated by a different or incompatible Go compiler version.","commonSituations":"Using a pre-serialized PGO profile generated by a different Go version (the serialization format may have changed). Profile corruption after generation. Caching serialized profiles across Go version upgrades.","solutions":["Regenerate the profile from a pprof CPU profile using the same Go toolchain version","Avoid reusing serialized profiles across Go major version upgrades","If using a profile cache, clear it after upgrading Go","Fall back to providing a raw pprof format profile instead of a serialized one"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify serialized profile compatibility by checking toolchain version\nimport (\n    \"os\"\n    \"runtime\"\n    \"strings\"\n)\n\nfunc checkSerializedProfileCompat(path string) error {\n    // Serialized profiles are version-specific — always regenerate with current toolchain\n    goVersion := runtime.Version() // e.g. go1.21.0\n    stat, err := os.Stat(path)\n    if err != nil {\n        return err\n    }\n    // If the profile is older than 30 days, recommend regeneration\n    if time.Since(stat.ModTime()) > 30*24*time.Hour {\n        return fmt.Errorf(\"profile may be stale (generated with older toolchain than %s), regenerate\", goVersion)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never reuse serialized PGO profiles across Go major version upgrades","Regenerate profiles with the same Go version you use for the production build","If caching serialized profiles, invalidate the cache when the Go toolchain changes","Prefer providing raw pprof profiles to the compiler — let it handle serialization"],"tags":["go-compiler","go-pgo","data-parsing","serialization","version-compatibility"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}