{"record":{"id":"a366001b1ce2ba97","repo":"go-delve/delve","slug":"could-not-find-compile-unit","errorCode":null,"errorMessage":"could not find compile unit","messagePattern":"could not find compile unit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/bininfo.go","lineNumber":1376,"sourceCode":"\n// LocationCovers returns the list of PC addresses that is covered by the\n// location attribute 'attr' of entry 'entry'.\nfunc (bi *BinaryInfo) LocationCovers(entry *dwarf.Entry, attr dwarf.Attr) ([][2]uint64, error) {\n\ta := entry.Val(attr)\n\tif a == nil {\n\t\treturn nil, fmt.Errorf(\"attribute %s not found\", attr)\n\t}\n\tif _, isblock := a.([]byte); isblock {\n\t\treturn [][2]uint64{{0, ^uint64(0)}}, nil\n\t}\n\n\toff, ok := a.(int64)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"attribute %s of unsupported type %T\", attr, a)\n\t}\n\tcu := bi.Images[0].findCompileUnitForOffset(entry.Offset)\n\tif cu == nil {\n\t\treturn nil, errors.New(\"could not find compile unit\")\n\t}\n\tif cu.Version >= 5 && cu.image.loclist5 != nil {\n\t\treturn nil, errors.New(\"LocationCovers does not support DWARFv5\")\n\t}\n\n\timage := cu.image\n\tbase := cu.lowPC\n\tif image == nil || image.loclist2.Empty() {\n\t\treturn nil, errors.New(\"malformed executable\")\n\t}\n\n\tr := [][2]uint64{}\n\tvar e loclist.Entry\n\timage.loclist2.Seek(int(off))\n\tfor image.loclist2.Next(&e) {\n\t\tif e.BaseAddressSelection() {\n\t\t\tbase = e.HighPC\n\t\t\tcontinue","sourceCodeStart":1358,"sourceCodeEnd":1394,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/bininfo.go#L1358-L1394","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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]"],"exampleFix":"// before\ncu := bi.Images[0].findCompileUnitForOffset(off) // nil -> error\n// after\nfor _, img := range bi.Images {\n    if cu := img.findCompileUnitForOffset(off); cu != nil { break }\n}","handlingStrategy":"validation","validationCode":"// verify the build matches before interpreting DWARF offsets\nif buildID(binaryPath) != buildID(debugInfoPath) {\n    return errors.New(\"binary and debug info come from different builds\")\n}","typeGuard":null,"tryCatchPattern":"cu, err := locationCovers(...)\nif err != nil && err.Error() == \"could not find compile unit\" {\n    // reload binary info from the current build and retry\n}","preventionTips":["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"],"tags":["dwarf","compile-unit","location-expressions","bininfo"],"backgroundTag":"compile-unit-not-found","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}