golang/go · error
read desc failed: %v
Error message
read desc failed: %v
What it means
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.
Source
Thrown at src/cmd/internal/buildid/note.go:63
break
}
return nil, fmt.Errorf("read namesize failed: %v", err)
}
err = binary.Read(r, f.ByteOrder, &descsize)
if err != nil {
return nil, fmt.Errorf("read descsize failed: %v", err)
}
err = binary.Read(r, f.ByteOrder, ¬eType)
if err != nil {
return nil, fmt.Errorf("read type failed: %v", err)
}
noteName, err := readAligned4(r, namesize)
if err != nil {
return nil, fmt.Errorf("read name failed: %v", err)
}
desc, err := readAligned4(r, descsize)
if err != nil {
return nil, fmt.Errorf("read desc failed: %v", err)
}
if name == string(noteName) && typ == noteType {
return desc, nil
}
}
}
return nil, nil
}
var elfGoNote = []byte("Go\x00\x00")
var elfGNUNote = []byte("GNU\x00")
// The Go build ID is stored in a note described by an ELF PT_NOTE prog
// header. The caller has already opened filename, to get f, and read
// at least 4 kB out, in data.
func readELF(name string, f *os.File, data []byte) (buildid string, err error) {
// Assume the note content is in the data, already read.
// Rewrite the ELF header to set shoff and shnum to 0, so that we can passView on GitHub (pinned to b6b368adc5)
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.
Defensive patterns
Strategy: try-catch
Try / catch
if _, err := buildid.ReadFile(bin); err != nil {
if strings.Contains(err.Error(), "read desc failed") {
return rebuild(bin) // build-id descriptor missing
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Truncated Go binaries missing the trailing build-id descriptor, corrupt cache entries, partially written link output, or stripped binaries where the descriptor was zeroed.
Related errors
- read namesize failed: %v
- read descsize failed: %v
- read type failed: %v
- read name failed: %v
- cannot find __text section
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/3fcdd0b0adfccd00.
Report an issue: GitHub.