{"record":{"id":"fae4e747bbb98163","repo":"go-delve/delve","slug":"reading-debug-info-file-reference-within-a-compil","errorCode":null,"errorMessage":"reading debug_info: file reference within a compilation unit without debug_line section at %#x","messagePattern":"reading debug_info: file reference within a compilation unit without debug_line section at %#x","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/bininfo.go","lineNumber":3245,"sourceCode":"\tr := make([]*PackageBuildInfo, 0, len(m))\n\tfor _, pbi := range m {\n\t\tr = append(r, pbi)\n\t}\n\n\tsort.Slice(r, func(i, j int) bool { return r[i].ImportPath < r[j].ImportPath })\n\treturn r\n}\n\n// cuFilePath takes a compilation unit \"cu\" and a file index reference\n// \"fileidx\" and returns the corresponding file name entry from the\n// DWARF line table associated with the unit; \"entry\" is the offset of\n// the attribute where the file reference originated, for logging\n// purposes. Return value is the file string and an error value; error\n// will be non-nil if the file could not be recovered, perhaps due to\n// malformed DWARF.\nfunc (cu *compileUnit) filePath(fileidx int, entry *dwarf.Entry) (string, error) {\n\tif cu.lineInfo == nil {\n\t\treturn \"\", fmt.Errorf(\"reading debug_info: file reference within a compilation unit without debug_line section at %#x\", entry.Offset)\n\t}\n\t// File numbering is slightly different before and after DWARF 5;\n\t// account for this here. See section 6.2.4 of the DWARF 5 spec.\n\tif cu.Version < 5 {\n\t\tfileidx--\n\t}\n\tif fileidx < 0 || fileidx >= len(cu.lineInfo.FileNames) {\n\t\treturn \"\", fmt.Errorf(\"reading debug_info: file index (%d) out of range in compile unit file table at %#x\", fileidx, entry.Offset)\n\t}\n\treturn cu.lineInfo.FileNames[fileidx].Path, nil\n}\n","sourceCodeStart":3227,"sourceCodeEnd":3257,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/bininfo.go#L3227-L3257","documentation":"Returned by (*compileUnit).filePath (pkg/proc/bininfo.go:3245) when a DWARF DIE references a file (DW_AT_decl_file or similar) but the compilation unit has no debug_line section loaded (cu.lineInfo == nil). Delve needs the CU's line program file table to resolve a numeric file index to a path; without debug_line the reference cannot be resolved, so this error signals malformed or incomplete DWARF.","triggerScenarios":"Reading DIEs of a compile unit whose debug_line section is missing from the binary or failed to parse, then calling filePath for an entry carrying a file index attribute; typically during function/variable/line-table mapping construction in loadBinaryInfo.","commonSituations":"Binaries stripped partially (debug_info kept, debug_line removed by custom strip tools), binaries linked from objects produced by non-Go compilers or linkers that drop .debug_line, corrupted download of the binary, DWARF emitted by exotic toolchains (cgo dependencies, Rust/C static libs).","solutions":["Rebuild the binary keeping full debug info (do not strip .debug_line; avoid -w and custom section strippers).","Verify the section exists with `readelf -S` / `objdump -h` (look for .debug_line / __debug_line); if missing, fix the build/strip pipeline.","Re-download or re-obtain the binary — a truncated or corrupted file can lose sections.","If produced by a third-party toolchain, check the linker flags (e.g. -Wl,--strip-debug vs full strip) and ensure DWARF is emitted for the offending compile unit."],"exampleFix":"// before: strip removes debug_line too\ngo build -o app .\nstrip --strip-debug app   # may drop needed DWARF sections\n\n// after: keep DWARF sections, or strip only symbols\ngo build -o app .\nstrip -s app   # or don't strip at all when debugging","handlingStrategy":"validation","validationCode":"# Ensure .debug_line exists before debugging/processing the binary:\nreadelf -S ./app | grep debug_line      # Linux/ELF\nobjdump -h ./app | grep debug_line      # alternative\necho $?  # non-empty grep means section present","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"without debug_line section\") {\n    return fmt.Errorf(\"binary lacks .debug_line; rebuild without stripping: %w\", err)\n}","preventionTips":["Never strip .debug_line from binaries destined for debugging.","Audit custom strip/objcopy steps in CI to confirm which DWARF sections they remove.","Verify downloaded binaries against checksums to rule out truncation.","Prefer `strip -s` (symbols only) over `--strip-debug` when DWARF is still needed."],"tags":["go","dwarf","debug-info","malformed-binary"],"backgroundTag":"missing-debug-line-section","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}