golang/go · error
read name failed: %v
Error message
read name failed: %v
What it means
Returned when readAligned4 fails reading the note name (e.g. "Go\x00\x00" or "GNU\x00") after the three header words parsed successfully. namesize bytes (padded to 4-byte alignment) could not be read, meaning the note's declared namesize extends past the section's actual bytes.
Source
Thrown at src/cmd/internal/buildid/note.go:59
var namesize, descsize, noteType int32
err = binary.Read(r, f.ByteOrder, &namesize)
if err != nil {
if err == io.EOF {
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 readView on GitHub (pinned to b6b368adc5)
Solutions
- Rebuild the affected binary from a clean source tree.
- Run `go clean -cache` to discard corrupt cached objects.
- Verify binary integrity (checksum, `file <bin>`).
- Eliminate any binary post-processing steps that rewrite note sections.
Defensive patterns
Strategy: try-catch
Try / catch
if _, err := buildid.ReadFile(bin); err != nil {
if strings.Contains(err.Error(), "read name failed") {
return rebuild(bin)
}
return err
} Prevention
- Validate ELF with `readelf -n <bin>` before relying on the build ID.
- Rebuild suspicious binaries rather than diagnose corrupt ones.
- Avoid binary post-processors that rewrite sections without fixing offsets.
When it happens
Trigger: An ELF note header advertises a namesize larger than the remaining section data, so readAligned4 returns an error. Common when namesize is garbage (corruption) or the section is truncated right after the header.
Common situations: Corrupt Go binaries where note header fields are inconsistent with section length; objects modified by a faulty post-link tool; mismatches between note producer and consumer expectations.
Related errors
- read namesize failed: %v
- read descsize failed: %v
- read type failed: %v
- read desc failed: %v
- cannot find __text section
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/39d898fd7b05433a.
Report an issue: GitHub.