{"record":{"id":"63fc70702aad2932","repo":"go-delve/delve","slug":"aligning-after-name-v","errorCode":null,"errorMessage":"aligning after name: %v","messagePattern":"aligning after name: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/core/linux_core.go","lineNumber":317,"sourceCode":"func readNote(r io.ReadSeeker, machineType elf.Machine) (*note, error) {\n\t// Notes are laid out as described in the SysV ABI:\n\t// https://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section\n\tnote := &note{}\n\thdr := &elfNotesHdr{}\n\n\terr := binary.Read(r, binary.LittleEndian, hdr)\n\tif err != nil {\n\t\treturn nil, err // don't wrap so readNotes sees EOF.\n\t}\n\tnote.Type = elf.NType(hdr.Type)\n\n\tname := make([]byte, hdr.Namesz)\n\tif _, err := r.Read(name); err != nil {\n\t\treturn nil, fmt.Errorf(\"reading name: %v\", err)\n\t}\n\tnote.Name = string(name)\n\tif err := skipPadding(r, 4); err != nil {\n\t\treturn nil, fmt.Errorf(\"aligning after name: %v\", err)\n\t}\n\tdesc := make([]byte, hdr.Descsz)\n\tif _, err := r.Read(desc); err != nil {\n\t\treturn nil, fmt.Errorf(\"reading desc: %v\", err)\n\t}\n\tdescReader := bytes.NewReader(desc)\n\tswitch note.Type {\n\tcase elf.NT_PRSTATUS:\n\t\tswitch machineType {\n\t\tcase _EM_X86_64:\n\t\t\tnote.Desc = &linuxPrStatusAMD64{}\n\t\tcase _EM_AARCH64:\n\t\t\tnote.Desc = &linuxPrStatusARM64{}\n\t\tcase _EM_RISCV:\n\t\t\tnote.Desc = &linuxPrStatusRISCV64{}\n\t\tcase _EM_LOONGARCH:\n\t\t\tnote.Desc = &linuxPrStatusLOONG64{}\n\t\tdefault:","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/core/linux_core.go#L299-L335","documentation":"readNote wraps any failure from skipPadding (which discards alignment bytes after the note's name field in an ELF core NT_* note) with this message. It means the core-file reader hit EOF or an I/O error while advancing to the 4-byte alignment boundary, so the note cannot be parsed. Delve throws it because a core dump with a truncated note stream cannot yield valid register/process notes.","triggerScenarios":"Opening a truncated or partially written ELF core dump (dlv core <binary> <core>) where the file ends immediately after the note name, before the 4-byte padding; also an underlying io.Reader error from the core file reader (r.Read failing on skipPadding).","commonSituations":"Core dump cut short by disk-full during dump collection, ulimit -c limits truncating the dump, copying the core file while the process was still dumping, or transferring a multi-GB core with rsync/scp interrupted.","solutions":["Re-capture the core dump, verifying its size matches what the dumping process wrote (no ulimit -c truncation).","Check disk space and file transfer integrity (checksum the core file) before opening it in Delve.","Verify the file is a complete ELF core (readelf -a <core> parses cleanly) and that the ELF program headers' sizes fit within the file.","If the dump is irrecoverable, debug from a re-run of the crash instead of repairing the truncated core."],"exampleFix":"// before\ncore, _ := os.Open(\"core\")\nfi, _ := core.Stat()\n// assuming fi.Size() bytes are valid\n// after\ncore, err := os.Open(\"core\")\nif err != nil { log.Fatal(err) }\nfi, err := core.Stat()\nif err != nil { log.Fatal(err) }\n// confirm note segments fit in the file before parsing\nif elfHeaderNoteOffset+noteSize > fi.Size() {\n    log.Fatalf(\"core file truncated: %d of %d bytes\", fi.Size(), expectedSize)\n}","handlingStrategy":"validation","validationCode":"// Before running dlv core, verify the ELF core's note data fits in the file:\nfunc validateCore(corePath string) error {\n    f, err := os.Open(corePath)\n    if err != nil { return err }\n    defer f.Close()\n    ef, err := elf.NewFile(f)\n    if err != nil { return fmt.Errorf(\"not a valid ELF file: %w\", err) }\n    if ef.Type != elf.ET_CORE { return fmt.Errorf(\"%s is not a core dump\", corePath) }\n    fi, _ := f.Stat()\n    for _, p := range ef.Progs {\n        end := p.Off + p.Filesz\n        if p.Type == elf.PT_NOTE && end > uint64(fi.Size()) {\n            return fmt.Errorf(\"core truncated: PT_NOTE extends to %d > file size %d\", end, fi.Size())\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set ulimit -c unlimited before running programs that may crash.","Monitor free disk space where core_pattern writes dumps.","Checksum core files after any transfer before debugging.","Sanity-check core files with readelf -n before loading them in Delve."],"tags":["core-dump","elf","io","truncated-file"],"backgroundTag":"truncated-core-file","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}