golang/go · error

read desc failed: %v

Error message

read desc failed: %v

What it means

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.

Source

Thrown at src/cmd/link/internal/ld/lib.go:2690

					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, &noteType)
			if err != nil {
				return nil, fmt.Errorf("read type failed: %v", err)
			}
			noteName, err := readwithpad(r, namesize)
			if err != nil {
				return nil, fmt.Errorf("read name failed: %v", err)
			}
			desc, err := readwithpad(r, descsize)
			if err != nil {
				return nil, fmt.Errorf("read desc failed: %v", err)
			}
			if string(name) == string(noteName) && typ == noteType {
				return desc, nil
			}
		}
	}
	return nil, nil
}

func findshlib(ctxt *Link, shlib string) string {
	if filepath.IsAbs(shlib) {
		return shlib
	}
	for _, libdir := range ctxt.Libdir {
		libpath := filepath.Join(libdir, shlib)
		if _, err := os.Stat(libpath); err == nil {
			return libpath
		}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Rebuild cgo/C objects with `go build -a`.
  2. Verify the object with `readelf -n`; discard and re-fetch if malformed.
  3. Ensure builds complete uninterrupted (no OOM-kill, no disk-full mid-write).
Defensive patterns

Strategy: validation

Validate before calling

for obj in $(find build -name '*.o'); do
  readelf -n "$obj" >/dev/null 2>&1 || echo "note descriptor truncated: $obj"
done

Try / catch

set +e
go build ./...
rc=$?
set -e
[ $rc -ne 0 ] && { go clean -cache; go build -a ./...; }

Prevention

When it happens

Trigger: 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.

Common situations: Interrupted compiler/assembler invocation leaving a partial `.o`; corrupted module cache; object transferred through a channel that stripped trailing bytes.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/71c90741d8535e64. Report an issue: GitHub.