{"record":{"id":"aeab70e91c729a2d","repo":"go-delve/delve","slug":"malformed-proc-pid-maps-on-line-d-q-wrong-num","errorCode":null,"errorMessage":"malformed /proc/pid/maps on line %d: %q (wrong number of fields)","messagePattern":"malformed /proc/pid/maps on line (.+?): %q \\(wrong number of fields\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/native/dump_linux.go","lineNumber":84,"sourceCode":"\t\t\tAddr: start,\n\t\t\tSize: end - start,\n\n\t\t\tRead:  perm[0] == 'r',\n\t\t\tWrite: perm[1] == 'w',\n\t\t\tExec:  perm[2] == 'x',\n\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}","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/native/dump_linux.go#L66-L102","documentation":"parseSmapsHeaderLine (pkg/proc/native/dump_linux.go), used by MemoryMap when building a Linux core dump, splits each /proc/pid/maps header line into at most 6 space-separated fields. The line did not yield exactly 6 fields, so it is not a valid maps entry and core dump generation aborts.","triggerScenarios":"MemoryMap reading a /proc/<pid>/maps (or smaps) file whose header line lacks the standard 'start-end perms offset dev inode [path]' layout — e.g. reading /proc/self/smaps sections, a kernel with different formatting, or reading the wrong file.","commonSituations":"Very unusual kernels or LXC/gVisor sandboxes that alter /proc/pid/maps output; accidentally pointing the parser at smaps instead of maps; race where the file is truncated mid-read; intercepted /proc via FUSE.","solutions":["Verify the process is reading /proc/<pid>/maps (not smaps or another pseudo-file).","Check the kernel/sandbox: run under a standard kernel or gVisor-free environment and retry.","Read the file atomically in one pass to avoid a truncated read; retry core dump creation.","If a sandbox rewrites maps lines, dump memory map manually and create the core with an alternative tool."],"exampleFix":"// before\nf, _ := os.Open(fmt.Sprintf(\"/proc/%d/smaps\", pid))\n// after\nf, _ := os.Open(fmt.Sprintf(\"/proc/%d/maps\", pid))","handlingStrategy":"validation","validationCode":"// Validate maps lines before parsing\ncount := len(strings.SplitN(line, \" \", 7))\nif count < 6 { return fmt.Errorf(\"skipping non-maps line: %q\", line) }","typeGuard":"func isMapsHeaderLine(line string) bool {\n    return len(strings.SplitN(strings.TrimSpace(line), \" \", 7)) == 6 && strings.Contains(strings.Fields(line)[0], \"-\")\n}","tryCatchPattern":"mm, err := MemoryMapFile(f)\nif err != nil && strings.Contains(err.Error(), \"wrong number of fields\") {\n    // fall back: re-read /proc/<pid>/maps fresh and retry once\n    f2, _ := os.Open(fmt.Sprintf(\"/proc/%d/maps\", pid)); mm, err = MemoryMapFile(f2)\n}","preventionTips":["Read /proc/<pid>/maps, never smaps/smaps_rollup, when building core dumps.","Read the whole file in one pass to avoid torn reads.","Test on standard kernels; verify sandbox (gVisor/LXC) doesn't rewrite procfs.","Log the offending line number and content for diagnosis."],"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"}