golang/go · error

d.LineReader: %v

Error message

d.LineReader: %v

What it means

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.

Source

Thrown at src/cmd/link/internal/dwtest/dwtest.go:177

	}
}

// FileRef takes a given DIE by index and a numeric file reference
// (presumably from a decl_file or call_file attribute), looks up the
// reference in the .debug_line file table, and returns the proper
// string for it. We need to know which DIE is making the reference
// so as to find the right compilation unit.
func (ex *Examiner) FileRef(dw *dwarf.Data, dieIdx int, fileRef int64) (string, error) {

	// Find the parent compilation unit DIE for the specified DIE.
	cuDie := ex.ParentCU(dieIdx)
	if cuDie == nil {
		return "", fmt.Errorf("no parent CU DIE for DIE with idx %d?", dieIdx)
	}
	// Construct a line reader and then use it to get the file string.
	lr, lrerr := dw.LineReader(cuDie)
	if lrerr != nil {
		return "", fmt.Errorf("d.LineReader: %v", lrerr)
	}
	files := lr.Files()
	if fileRef < 0 || int(fileRef) > len(files)-1 {
		return "", fmt.Errorf("Examiner.FileRef: malformed file reference %d", fileRef)
	}
	return files[fileRef].Name, nil
}

// Return a list of all DIEs with name 'name'. When searching for DIEs
// by name, keep in mind that the returned results will include child
// DIEs such as params/variables. For example, asking for all DIEs named
// "p" for even a small program will give you 400-500 entries.
func (ex *Examiner) Named(name string) []*dwarf.Entry {
	sl := ex.byname[name]
	ret := make([]*dwarf.Entry, len(sl))
	for i, k := range sl {
		ret[i] = ex.entryFromIdx(k)
	}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Inspect the wrapped lrerr to identify the exact line-reader failure (truncation, bad offset, version).
  2. Rebuild the binary with full DWARF (-ldflags=-w disabled) and confirm .debug_line is present.
  3. Only run dwtest's Examiner on output produced by the Go linker under test.
  4. If the CU DIE lacks a line program, skip FileRef for that DIE (check cuDie.Val(AttrStmtList) first).
Defensive patterns

Strategy: try-catch

Validate before calling

// Guard: only call FileRef when the CU DIE advertises a line program.
if cuDie.Val(dwarf.AttrStmtList) == nil {
    return "", nil // no line program; skip
}

Try / catch

name, err := ex.FileRef(dw, dieIdx, fileRef)
if err != nil {
    // line reader failure — log and skip this DIE rather than abort the whole scan
    log.Printf("skip DIE %d: %v", dieIdx, err)
    continue
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/1a1a4592ca303795. Report an issue: GitHub.