{"record":{"id":"6284a6729d996c3c","repo":"go-delve/delve","slug":"malformed-delve-header-note-bad-pid-v","errorCode":null,"errorMessage":"malformed delve header note (bad pid): %v","messagePattern":"malformed delve header note \\(bad pid\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/core/delve_core.go","lineNumber":47,"sourceCode":"\nfunc threadsFromDelveNotes(p *process, notes []*note) (proc.Thread, error) {\n\tvar currentThread proc.Thread\n\tfor _, note := range notes {\n\t\tif note.Type == elfwriter.DelveHeaderNoteType {\n\t\t\tbuf := bytes.NewBuffer(note.Desc.([]byte))\n\t\t\tfor {\n\t\t\t\tline, err := buf.ReadString('\\n')\n\t\t\t\tif err != nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif len(line) > 0 && line[len(line)-1] == '\\n' {\n\t\t\t\t\tline = line[:len(line)-1]\n\t\t\t\t}\n\t\t\t\tswitch {\n\t\t\t\tcase strings.HasPrefix(line, elfwriter.DelveHeaderTargetPidPrefix):\n\t\t\t\t\tpid, err := strconv.ParseUint(line[len(elfwriter.DelveHeaderTargetPidPrefix):], 10, 64)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"malformed delve header note (bad pid): %v\", err)\n\t\t\t\t\t}\n\t\t\t\t\tp.pid = int(pid)\n\t\t\t\tcase strings.HasPrefix(line, elfwriter.DelveHeaderEntryPointPrefix):\n\t\t\t\t\tentry, err := strconv.ParseUint(line[len(elfwriter.DelveHeaderEntryPointPrefix):], 0, 64)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"malformed delve header note (bad entry point): %v\", err)\n\t\t\t\t\t}\n\t\t\t\t\tp.entryPoint = entry\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif note.Type != elfwriter.DelveThreadNodeType {\n\t\t\tcontinue\n\t\t}\n\t\tbody := bytes.NewReader(note.Desc.([]byte))\n\t\tth := new(delveThread)\n\t\tth.regs = new(delveRegisters)","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/core/delve_core.go#L29-L65","documentation":"threadsFromDelveNotes reads the delve header note line-by-line; the line beginning with DelveHeaderTargetPidPrefix must be a decimal number for strconv.ParseUint to succeed. A non-numeric PID value causes this error, aborting core parsing.","triggerScenarios":"readLinuxOrPlatformIndependentCore -> threadsFromDelveNotes encounters a header-note line like 'pid: abc' or an empty value after the PID prefix, so ParseUint(base 10, 64) fails.","commonSituations":"Hand-edited core notes; writing tools that emit the PID in hex (0x...) or with extra characters; truncated note payload cutting off digits.","solutions":["Fix the header note so the PID line is a plain decimal number, e.g. 'pid: 12345'.","Regenerate the core dump with delve rather than editing the note manually.","Verify the note payload was not truncated (check Descsz vs actual bytes).","Confirm the producing tool's delve version matches the reading version's note format."],"exampleFix":"// before\n\"pid: 0x3039\" // hex not accepted\n// after\n\"pid: 12345\" // decimal only","handlingStrategy":"validation","validationCode":"// Validate PID line before parsing\npidStr := strings.TrimPrefix(line, DelveHeaderTargetPidPrefix)\nif _, err := strconv.ParseUint(pidStr, 10, 64); err != nil {\n\treturn fmt.Errorf(\"core note pid %q is not decimal\", pidStr)\n}","typeGuard":"func isDecimal(s string) bool {\n\t_, err := strconv.ParseUint(s, 10, 64)\n\treturn err == nil\n}","tryCatchPattern":null,"preventionTips":["Emit the pid as plain decimal in note-producing tools.","Avoid manual edits to core notes.","Check note payload completeness after writing.","Pin delve versions across dump/analyze workflows."],"tags":["core-dump","elf-notes","parse-error"],"backgroundTag":"malformed-core-header-note","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}