{"record":{"id":"1a1a4592ca303795","repo":"golang/go","slug":"d-linereader-v","errorCode":null,"errorMessage":"d.LineReader: %v","messagePattern":"d\\.LineReader: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/link/internal/dwtest/dwtest.go","lineNumber":177,"sourceCode":"\t}\n}\n\n// FileRef takes a given DIE by index and a numeric file reference\n// (presumably from a decl_file or call_file attribute), looks up the\n// reference in the .debug_line file table, and returns the proper\n// string for it. We need to know which DIE is making the reference\n// so as to find the right compilation unit.\nfunc (ex *Examiner) FileRef(dw *dwarf.Data, dieIdx int, fileRef int64) (string, error) {\n\n\t// Find the parent compilation unit DIE for the specified DIE.\n\tcuDie := ex.ParentCU(dieIdx)\n\tif cuDie == nil {\n\t\treturn \"\", fmt.Errorf(\"no parent CU DIE for DIE with idx %d?\", dieIdx)\n\t}\n\t// Construct a line reader and then use it to get the file string.\n\tlr, lrerr := dw.LineReader(cuDie)\n\tif lrerr != nil {\n\t\treturn \"\", fmt.Errorf(\"d.LineReader: %v\", lrerr)\n\t}\n\tfiles := lr.Files()\n\tif fileRef < 0 || int(fileRef) > len(files)-1 {\n\t\treturn \"\", fmt.Errorf(\"Examiner.FileRef: malformed file reference %d\", fileRef)\n\t}\n\treturn files[fileRef].Name, nil\n}\n\n// Return a list of all DIEs with name 'name'. When searching for DIEs\n// by name, keep in mind that the returned results will include child\n// DIEs such as params/variables. For example, asking for all DIEs named\n// \"p\" for even a small program will give you 400-500 entries.\nfunc (ex *Examiner) Named(name string) []*dwarf.Entry {\n\tsl := ex.byname[name]\n\tret := make([]*dwarf.Entry, len(sl))\n\tfor i, k := range sl {\n\t\tret[i] = ex.entryFromIdx(k)\n\t}","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/link/internal/dwtest/dwtest.go#L159-L195","documentation":"Thrown by Examiner.FileRef in the linker's DWARF test examiner (dwtest.go:175-178) when dw.LineReader(cuDie) returns an error. FileRef needs a line reader for the DIE's parent compilation unit to translate a numeric file reference into a file name; if the line reader cannot be constructed the lookup aborts. The %v wraps the underlying debug/dwarf.LineReader error.","triggerScenarios":"The parent CU DIE is missing or has a malformed line-program offset; the .debug_line section is truncated or corrupt; reading a binary whose DWARF version the examiner does not handle. dw.LineReader returns a non-nil error at dwtest.go:175-176.","commonSituations":"Linker bug producing inconsistent .debug_info/.debug_line; examining a stripped or non-Go binary; DWARF5 with directory/file table formats the reader rejects; partial build where .debug_line was dropped.","solutions":["Inspect the wrapped lrerr to identify the exact line-reader failure (truncation, bad offset, version).","Rebuild the binary with full DWARF (-ldflags=-w disabled) and confirm .debug_line is present.","Only run dwtest's Examiner on output produced by the Go linker under test.","If the CU DIE lacks a line program, skip FileRef for that DIE (check cuDie.Val(AttrStmtList) first)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Guard: only call FileRef when the CU DIE advertises a line program.\nif cuDie.Val(dwarf.AttrStmtList) == nil {\n    return \"\", nil // no line program; skip\n}","typeGuard":null,"tryCatchPattern":"name, err := ex.FileRef(dw, dieIdx, fileRef)\nif err != nil {\n    // line reader failure — log and skip this DIE rather than abort the whole scan\n    log.Printf(\"skip DIE %d: %v\", dieIdx, err)\n    continue\n}","preventionTips":["Only run the Examiner on complete, unstripped Go-linker output.","Verify .debug_line is present before analysis (do not strip with -ldflags=-w).","Check cuDie has a DW_AT_stmtlist before invoking FileRef."],"tags":["dwarf","go-linker","dwtest","debug-info"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}