{"record":{"id":"3fcdd0b0adfccd00","repo":"golang/go","slug":"read-desc-failed-v","errorCode":null,"errorMessage":"read desc failed: %v","messagePattern":"read desc failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/buildid/note.go","lineNumber":63,"sourceCode":"\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}\n\treturn nil, nil\n}\n\nvar elfGoNote = []byte(\"Go\\x00\\x00\")\nvar elfGNUNote = []byte(\"GNU\\x00\")\n\n// The Go build ID is stored in a note described by an ELF PT_NOTE prog\n// header. The caller has already opened filename, to get f, and read\n// at least 4 kB out, in data.\nfunc readELF(name string, f *os.File, data []byte) (buildid string, err error) {\n\t// Assume the note content is in the data, already read.\n\t// Rewrite the ELF header to set shoff and shnum to 0, so that we can pass","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/buildid/note.go#L45-L81","documentation":"Returned when readAligned4 fails reading the note descriptor (desc) bytes after the name was read. descsize bytes (4-byte aligned) could not be satisfied, so the build-id payload itself is missing or truncated. The Go build ID lives in this descriptor for NT_VERSION notes.","triggerScenarios":"An ELF note declares a descsize larger than the section contains after the header+name, so readAligned4 errors reading desc. The note passes header/name checks but the actual build-id bytes are unavailable.","commonSituations":"Truncated Go binaries missing the trailing build-id descriptor, corrupt cache entries, partially written link output, or stripped binaries where the descriptor was zeroed.","solutions":["Rebuild the binary so the build-id descriptor is written in full.","Clean the cache: `go clean -cache`.","Confirm the binary was not stripped of its Go note (`file`, `readelf -n <bin>`).","Re-fetch the file if transferred incompletely."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := buildid.ReadFile(bin); err != nil {\n    if strings.Contains(err.Error(), \"read desc failed\") {\n        return rebuild(bin) // build-id descriptor missing\n    }\n    return err\n}","preventionTips":["Do not strip Go binaries of their NT_VERSION note.","Re-fetched binaries should match an expected checksum.","Clean cache (`go clean -cache`) after crashes during link."],"tags":["buildid","elf","binary","corruption"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}