go-delve/delve · error

aligning after desc: %v

Error message

aligning after desc: %v

What it means

readNote wraps a skipPadding failure after the note descriptor with this message. ELF notes require the descriptor to be padded to a 4-byte boundary; when the reader can't consume that padding (EOF or I/O error), the note stream is considered corrupt. Delve throws it because subsequent notes cannot be located reliably.

Source

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

			}
			note.Desc = &fpregs
		}
	case _NT_AUXV, elfwriter.DelveHeaderNoteType, elfwriter.DelveThreadNodeType:
		note.Desc = desc
	case _NT_FPREGSET:
		if machineType == _EM_AARCH64 {
			err = readFpregsetNote(note, &linutil.ARM64PtraceFpRegs{}, desc[:_ARM_FP_HEADER_START])
		} else if machineType == _EM_RISCV {
			err = readFpregsetNote(note, &linutil.RISCV64PtraceFpRegs{}, desc)
		} else if machineType == _EM_LOONGARCH {
			err = readFpregsetNote(note, &linutil.LOONG64PtraceFpRegs{}, desc)
		}
		if err != nil {
			return nil, err
		}
	}
	if err := skipPadding(r, 4); err != nil {
		return nil, fmt.Errorf("aligning after desc: %v", err)
	}
	return note, nil
}

func readFpregsetNote(note *note, fpregs interface{ Byte() []byte }, desc []byte) error {
	rdr := bytes.NewReader(desc)
	if err := binary.Read(rdr, binary.LittleEndian, fpregs.Byte()); err != nil {
		return err
	}
	note.Desc = fpregs
	return nil
}

// skipPadding moves r to the next multiple of pad.
func skipPadding(r io.ReadSeeker, pad int64) error {
	pos, err := r.Seek(0, io.SeekCurrent)
	if err != nil {
		return err

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Re-capture the core with a standard dumper (kernel or gcore) so all notes are 4-byte aligned.
  2. Check the file size against the NOTES segment size in the ELF program headers (readelf -l <core>).
  3. If the last note is the problem and earlier notes are intact, tolerate the truncation by re-dumping anyway — partial cores are unreliable.
  4. Verify transfer integrity (checksums) before debugging.

Example fix

// before
notes, err := readNotes(...) // fails on last note padding
if err != nil { return err } // whole core rejected
// after
notes, err := readNotes(...)
if err != nil {
    log.Printf("warning: core notes truncated: %v", err)
    // proceed only if >=1 complete PRSTATUS note was read
    if len(notes) == 0 { return err }
}
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the PT_NOTE segment is 4-byte aligned and fully present:
for _, p := range elfFile.Progs {
    if p.Type == elf.PT_NOTE && (p.Filesz%4 != 0 || p.Off+p.Filesz > fileSize) {
        return fmt.Errorf("core PT_NOTE malformed or truncated: off=%d size=%d", p.Off, p.Filesz)
    }
}

Prevention

When it happens

Trigger: The core file ends exactly at the end of the note descriptor with no 4-byte alignment padding; or r.Read fails during skipPadding while iterating NOTES in dlv core parsing.

Common situations: Dumps truncated by ulimit -c or disk-full right at a note boundary; interrupted file copies; custom dumpers that omit alignment padding (technically malformed ELF cores).

Related errors


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