go-delve/delve · error

reading NT_PRSTATUS: %v

Error message

reading NT_PRSTATUS: %v

What it means

This error occurs when binary.Read fails to decode the NT_PRSTATUS note descriptor into the architecture-specific linuxPrStatus struct (registers, signal, PID, etc.) for the core's machine type. It usually means the descriptor is shorter than the expected struct size, i.e. the core is truncated or produced by an incompatible kernel/architecture layout.

Source

Thrown at pkg/proc/core/linux_core.go:339

		return nil, fmt.Errorf("reading desc: %v", err)
	}
	descReader := bytes.NewReader(desc)
	switch note.Type {
	case elf.NT_PRSTATUS:
		switch machineType {
		case _EM_X86_64:
			note.Desc = &linuxPrStatusAMD64{}
		case _EM_AARCH64:
			note.Desc = &linuxPrStatusARM64{}
		case _EM_RISCV:
			note.Desc = &linuxPrStatusRISCV64{}
		case _EM_LOONGARCH:
			note.Desc = &linuxPrStatusLOONG64{}
		default:
			return nil, errors.New("unsupported machine type")
		}
		if err := binary.Read(descReader, binary.LittleEndian, note.Desc); err != nil {
			return nil, fmt.Errorf("reading NT_PRSTATUS: %v", err)
		}
	case elf.NT_PRPSINFO:
		note.Desc = &linuxPrPsInfo{}
		if err := binary.Read(descReader, binary.LittleEndian, note.Desc); err != nil {
			return nil, fmt.Errorf("reading NT_PRPSINFO: %v", err)
		}
	case _NT_FILE:
		// No good documentation reference, but the structure is
		// simply a header, including entry count, followed by that
		// many entries, and then the file name of each entry,
		// null-delimited. Not reading the names here.
		data := &linuxNTFile{}
		if err := binary.Read(descReader, binary.LittleEndian, &data.linuxNTFileHdr); err != nil {
			return nil, fmt.Errorf("reading NT_FILE header: %v", err)
		}
		for i := 0; i < int(data.Count); i++ {
			entry := &linuxNTFileEntry{}
			if err := binary.Read(descReader, binary.LittleEndian, entry); err != nil {

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Confirm the core's architecture matches the binary you pass to dlv core (file <core>, readelf -h <core>).
  2. Re-capture the core dump; verify with readelf -n <core> that NT_PRSTATUS is present and intact.
  3. Ensure Delve supports the core's machine type (x86_64, arm64, i386, ppc64le, riscv64, loong64); unsupported pairs fail earlier with 'unsupported machine type'.
  4. Check that the core was produced by a Linux kernel using the standard ELF PrStatus layout for that architecture.

Example fix

// before
cmd := exec.Command("dlv", "core", amd64Binary, arm64Core) // arch mismatch
// after
coreArch := readELFMachine(arm64Core) // e.g. via readelf -h
binArch := readELFMachine(amd64Binary)
if coreArch != binArch {
    return fmt.Errorf("architecture mismatch: core is %s, binary is %s", coreArch, binArch)
}
Defensive patterns

Strategy: validation

Validate before calling

// Ensure core and binary architectures match before debugging:
func archMatches(corePath, binPath string) (bool, error) {
    for _, p := range []string{corePath, binPath} {
        f, err := os.Open(p)
        if err != nil { return false, err }
        ef, err := elf.NewFile(f)
        f.Close()
        if err != nil { return false, fmt.Errorf("%s: %w", p, err) }
        _ = ef.Machine
    }
    return elfMachine(corePath) == elfMachine(binPath), nil
}

Prevention

When it happens

Trigger: Parsing a core file whose NT_PRSTATUS descriptor has fewer bytes than the struct (linuxPrStatusAMD64/linuxPrStatusARM64/.../linuxPrStatusLOONG64) requires; corrupted or mixed-endianness core files also fail here.

Common situations: Opening an arm64 or loong64 core on a build whose struct layout doesn't match the producing kernel, truncated dumps, or cores generated on other machines with mismatched architecture vs. the ELF machine type recorded.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/6cc5b2bb3981c8fc. Report an issue: GitHub.