{"record":{"id":"1e302bce0dd8f528","repo":"golang/go","slug":"read-descsize-failed-v","errorCode":null,"errorMessage":"read descsize failed: %v","messagePattern":"read descsize failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/buildid/note.go","lineNumber":51,"sourceCode":"\t}\n\tdefer f.Close()\n\tfor _, sect := range f.Sections {\n\t\tif sect.Type != elf.SHT_NOTE {\n\t\t\tcontinue\n\t\t}\n\t\tr := sect.Open()\n\t\tfor {\n\t\t\tvar namesize, descsize, noteType int32\n\t\t\terr = binary.Read(r, f.ByteOrder, &namesize)\n\t\t\tif err != nil {\n\t\t\t\tif err == io.EOF {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\treturn nil, fmt.Errorf(\"read namesize failed: %v\", err)\n\t\t\t}\n\t\t\terr = binary.Read(r, f.ByteOrder, &descsize)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"read descsize failed: %v\", err)\n\t\t\t}\n\t\t\terr = binary.Read(r, f.ByteOrder, &noteType)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"read type failed: %v\", err)\n\t\t\t}\n\t\t\tnoteName, err := readAligned4(r, namesize)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"read name failed: %v\", err)\n\t\t\t}\n\t\t\tdesc, err := readAligned4(r, descsize)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"read desc failed: %v\", err)\n\t\t\t}\n\t\t\tif name == string(noteName) && typ == noteType {\n\t\t\t\treturn desc, nil\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/buildid/note.go#L33-L69","documentation":"Returned after successfully reading namesize when binary.Read of the descsize field fails (non-EOF). The ELF note header is namesize(4) + descsize(4) + type(4); failing on the second word means the section ended prematurely between fields. Wrapped and propagated from the note reader.","triggerScenarios":"Reading an ELF note section whose header is at least 4 bytes but fewer than 8, so namesize parses but descsize does not. Produced by the same code path as error 1227 when corruption lands mid-header.","commonSituations":"Truncated ELF note sections in partially linked or partially downloaded Go binaries; corrupt object cache entries; hand-modified binaries.","solutions":["Rebuild the binary from source.","Clean the build cache: `go clean -cache`.","Check the binary was completely written (size, checksums, `file <bin>`).","Avoid stripping or post-processing the binary with tools that truncate note sections."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := buildid.ReadFile(bin); err != nil {\n    if strings.Contains(err.Error(), \"read descsize failed\") {\n        return rebuild(bin) // truncated ELF note header\n    }\n    return err\n}","preventionTips":["Ensure link steps complete without interruption.","Checksum large binaries after transfer.","Run `go clean -cache` when corrupt objects are suspected."],"tags":["buildid","elf","binary","corruption"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}