go-delve/delve · error
could not find compile unit
Error message
could not find compile unit
What it means
LocationCovers resolves the PC ranges covered by a location expression; it first looks up the compile unit (CU) that contains the DWARF entry's offset. This error means no compile unit in bi.Images[0] claims that offset — the DIE referenced does not belong to any known CU, so its location list cannot be interpreted.
Source
Thrown at pkg/proc/bininfo.go:1376
// LocationCovers returns the list of PC addresses that is covered by the
// location attribute 'attr' of entry 'entry'.
func (bi *BinaryInfo) LocationCovers(entry *dwarf.Entry, attr dwarf.Attr) ([][2]uint64, error) {
a := entry.Val(attr)
if a == nil {
return nil, fmt.Errorf("attribute %s not found", attr)
}
if _, isblock := a.([]byte); isblock {
return [][2]uint64{{0, ^uint64(0)}}, nil
}
off, ok := a.(int64)
if !ok {
return nil, fmt.Errorf("attribute %s of unsupported type %T", attr, a)
}
cu := bi.Images[0].findCompileUnitForOffset(entry.Offset)
if cu == nil {
return nil, errors.New("could not find compile unit")
}
if cu.Version >= 5 && cu.image.loclist5 != nil {
return nil, errors.New("LocationCovers does not support DWARFv5")
}
image := cu.image
base := cu.lowPC
if image == nil || image.loclist2.Empty() {
return nil, errors.New("malformed executable")
}
r := [][2]uint64{}
var e loclist.Entry
image.loclist2.Seek(int(off))
for image.loclist2.Next(&e) {
if e.BaseAddressSelection() {
base = e.HighPC
continueView on GitHub (pinned to a23773e6c3)
Solutions
- Ensure the debug info and the running binary come from the exact same build (same build-id)
- Reload the binary info after rebuilding the target
- Verify the image containing the entry is loaded (Images[0] must be the image owning the entry)
- If writing tooling, resolve the CU through the correct image instead of assuming Images[0]
Example fix
// before
cu := bi.Images[0].findCompileUnitForOffset(off) // nil -> error
// after
for _, img := range bi.Images {
if cu := img.findCompileUnitForOffset(off); cu != nil { break }
} Defensive patterns
Strategy: validation
Validate before calling
// verify the build matches before interpreting DWARF offsets
if buildID(binaryPath) != buildID(debugInfoPath) {
return errors.New("binary and debug info come from different builds")
} Try / catch
cu, err := locationCovers(...)
if err != nil && err.Error() == "could not find compile unit" {
// reload binary info from the current build and retry
} Prevention
- Always pair the DWARF data with the exact same binary build
- Reload BinaryInfo after recompiling the target
- Don't cache DIE offsets across binary replacements
When it happens
Trigger: Calling LocationCovers with a loclist/DIE entry whose Offset does not fall inside any compile unit found by findCompileUnitForOffset; using stale DWARF offsets from a mismatched or outdated binary.
Common situations: Mixing executable and symbol files from different builds (build mismatch after recompile); corrupt or truncated .debug_info; tooling that hands Delve raw offsets from the wrong image.
Related errors
- ErrStackUnderflow
- ErrStackIndexOutOfBounds
- ErrMemoryReadUnavailable
- empty OP stack
- could not retrieve CFA for current PC
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/a366001b1ce2ba97.
Report an issue: GitHub.