golang/go · error

read type failed: %v

Error message

read type failed: %v

What it means

The third header word of an ELF note is the 4-byte `noteType`. After `namesize` and `descsize` are read successfully, a failure reading `noteType` indicates a note record whose header is incomplete (e.g. a section length claiming room for two notes but only fitting part of a third). The linker refuses to guess the type and aborts.

Source

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

			continue
		}
		r := sect.Open()
		for {
			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, &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 {

View on GitHub (pinned to b6b368adc5)

Solutions

  1. `go clean -cache && go build -a` to rebuild objects.
  2. Cross-check with `readelf -n <object>` — a clean object yields a parseable note list.
  3. Reinstall/upgrade the C toolchain if its objects consistently produce malformed notes.
Defensive patterns

Strategy: validation

Validate before calling

# readelf -n exits non-zero / reports errors on malformed notes
for obj in $(find build -name '*.o'); do
  readelf -n "$obj" >/dev/null 2>&1 || echo "note header corrupt: $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 `SHT_NOTE` section length not aligned to full note records, leaving a partial trailing header; an object generated by a compiler/assembler that miscalculated note sizes; filesystem corruption altering the section's contents.

Common situations: Object built with a buggy nightly/binutils snapshot; corrupt cache after a hard reset; mixing objects from different endianness toolchains.

Related errors


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