{"record":{"id":"39d898fd7b05433a","repo":"golang/go","slug":"read-name-failed-v","errorCode":null,"errorMessage":"read name failed: %v","messagePattern":"read name failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/buildid/note.go","lineNumber":59,"sourceCode":"\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}\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","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/buildid/note.go#L41-L77","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := buildid.ReadFile(bin); err != nil {\n    if strings.Contains(err.Error(), \"read name failed\") {\n        return rebuild(bin)\n    }\n    return err\n}","preventionTips":["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."],"tags":["buildid","elf","binary","corruption"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}