{"record":{"id":"0111ef5d6b9cee43","repo":"go-delve/delve","slug":"malformed-proc-pid-maps-on-line-d-q-bad-first","errorCode":null,"errorMessage":"malformed /proc/pid/maps on line %d: %q (bad first field)","messagePattern":"malformed /proc/pid/maps on line (.+?): %q \\(bad first field\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/native/dump_linux.go","lineNumber":90,"sourceCode":"\n\t\t\tFilename: filename,\n\t\t\tOffset:   offset,\n\t\t})\n\n\t}\n\treturn r, nil\n}\n\nfunc parseSmapsHeaderLine(lineno int, in string) (start, end uint64, perm string, offset uint64, dev, filename string, err error) {\n\tfields := strings.SplitN(in, \" \", 6)\n\tif len(fields) != 6 {\n\t\terr = fmt.Errorf(\"malformed /proc/pid/maps on line %d: %q (wrong number of fields)\", lineno, in)\n\t\treturn\n\t}\n\n\tv := strings.Split(fields[0], \"-\")\n\tif len(v) != 2 {\n\t\terr = fmt.Errorf(\"malformed /proc/pid/maps on line %d: %q (bad first field)\", lineno, in)\n\t\treturn\n\t}\n\tstart, err = strconv.ParseUint(v[0], 16, 64)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"malformed /proc/pid/maps on line %d: %q (%v)\", lineno, in, err)\n\t\treturn\n\t}\n\tend, err = strconv.ParseUint(v[1], 16, 64)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"malformed /proc/pid/maps on line %d: %q (%v)\", lineno, in, err)\n\t\treturn\n\t}\n\n\tperm = fields[1]\n\tif len(perm) < 4 {\n\t\terr = fmt.Errorf(\"malformed /proc/pid/maps on line %d: %q (permissions column too short)\", lineno, in)\n\t\treturn\n\t}","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/native/dump_linux.go#L72-L108","documentation":"The maps line had 6 fields but the first field could not be split on '-' into exactly two parts. The first column of /proc/pid/maps must be '<hexstart>-<hexend>'; anything else is malformed and MemoryMap cannot build the memory map.","triggerScenarios":"parseSmapsHeaderLine encountering a line whose fields[0] has no '-' or more than one '-' — e.g. an smaps 'Size: 4 kB' style key/value line fed to the header parser, or a corrupted/foreign maps format.","commonSituations":"Parsing /proc/pid/smaps or smaps_rollup (which contain 'Key: value' lines) instead of maps; third-party procfs shims with different formatting.","solutions":["Make sure the file being parsed is /proc/<pid>/maps, not smaps/smaps_rollup.","Filter out non-header lines (lines containing ':') before calling the parser.","Retry after re-reading the file completely — a torn read can splice lines.","If the kernel uses a nonstandard format, normalize lines before parsing."],"exampleFix":"// before: line fed directly from smaps\n\"Size:                132 kB\"  // fields[0] = \"Size:\" -> no '-'\n// after: only header lines contain '-' in field 0\nif !strings.HasPrefix(fields[0], \"\") && strings.Contains(fields[0], \"-\") { parseSmapsHeaderLine(...) }","handlingStrategy":"validation","validationCode":"fields0 := strings.Fields(line)[0]\nparts := strings.Split(fields0, \"-\")\nif len(parts) != 2 { return fmt.Errorf(\"not a maps header: %q\", line) }\nif _, err := strconv.ParseUint(parts[0], 16, 64); err != nil { return err }","typeGuard":"func looksLikeMapsRange(field string) bool {\n    v := strings.Split(field, \"-\")\n    return len(v) == 2 && isHex(v[0]) && isHex(v[1])\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"bad first field\") {\n    // skip smaps-style key/value lines and continue parsing the rest\n    continue\n}","preventionTips":["Filter out 'Key: value' lines (smaps output) before parsing.","Pre-validate each line with a regex like ^[0-9a-f]+-[0-9a-f]+\\s before parsing.","Use cat /proc/<pid>/maps as the reference format for generated fixtures.","Avoid parsing maps files captured through logging/mangling layers."],"tags":["linux","procfs","core-dump","delve"],"backgroundTag":"malformed-proc-maps-line","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}