{"record":{"id":"71c90741d8535e64","repo":"golang/go","slug":"read-desc-failed-v-71c907","errorCode":null,"errorMessage":"read desc failed: %v","messagePattern":"read desc failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/link/internal/ld/lib.go","lineNumber":2690,"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 := readwithpad(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 := readwithpad(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 string(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\nfunc findshlib(ctxt *Link, shlib string) string {\n\tif filepath.IsAbs(shlib) {\n\t\treturn shlib\n\t}\n\tfor _, libdir := range ctxt.Libdir {\n\t\tlibpath := filepath.Join(libdir, shlib)\n\t\tif _, err := os.Stat(libpath); err == nil {\n\t\t\treturn libpath\n\t\t}","sourceCodeStart":2672,"sourceCodeEnd":2708,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/link/internal/ld/lib.go#L2672-L2708","documentation":"After the note name, the linker reads `descsize` bytes of descriptor (with padding). A failure means the descriptor payload declared by the header is not actually present — the note is truncated after its name. Since the descriptor is the payload the linker is searching for, it cannot continue and aborts.","triggerScenarios":"A note whose `descsize` exceeds the remaining section length; an object truncated mid-write; a section length rounded down incorrectly so the last note's descriptor is cut off.","commonSituations":"Interrupted compiler/assembler invocation leaving a partial `.o`; corrupted module cache; object transferred through a channel that stripped trailing bytes.","solutions":["Rebuild cgo/C objects with `go build -a`.","Verify the object with `readelf -n`; discard and re-fetch if malformed.","Ensure builds complete uninterrupted (no OOM-kill, no disk-full mid-write)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for obj in $(find build -name '*.o'); do\n  readelf -n \"$obj\" >/dev/null 2>&1 || echo \"note descriptor truncated: $obj\"\ndone","typeGuard":null,"tryCatchPattern":"set +e\ngo build ./...\nrc=$?\nset -e\n[ $rc -ne 0 ] && { go clean -cache; go build -a ./...; }","preventionTips":["Ensure compiler/assembler runs complete uninterrupted.","Re-fetch dependencies if archives may be truncated.","Validate note sections in CI."],"tags":["linker","go-toolchain","elf","cgo","note-section"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}