{"record":{"id":"71fb52695d45b070","repo":"go-delve/delve","slug":"disassemble-failed-with-error-w","errorCode":null,"errorMessage":"disassemble failed with error %w","messagePattern":"disassemble failed with error %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/debugger/debugger.go","lineNumber":1455,"sourceCode":"\t\tif parent.Depth > followCalls {\n\t\t\tcontinue\n\t\t}\n\t\tif !parent.visited {\n\t\t\tfuncs = append(funcs, parent.Func.Name)\n\t\t\tparent.visited = true\n\t\t} else if parent.visited {\n\t\t\tcontinue\n\t\t}\n\n\t\tif parent.Depth+1 > followCalls {\n\t\t\t// Avoid diassembling if we already cross the follow-calls depth\n\t\t\tcontinue\n\t\t}\n\t\tf := parent.Func\n\t\ttext, err := proc.Disassemble(t.Memory(), nil, t.Breakpoints(), t.BinInfo(), f.Entry, f.End)\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"disassemble failed with error %w\", err)\n\t\t}\n\t\tfor _, instr := range text {\n\t\t\t// Dynamic functions need to be handled specially as their destination location\n\t\t\t// is not known statically, hence its required to put a breakpoint in order to\n\t\t\t// acquire the address of the function at runtime and we do this via a\n\t\t\t// call back mechanism\n\t\t\tif instr.IsCall() && instr.DestLoc == nil {\n\t\t\t\tdynbp, err := t.SetBreakpoint(0, instr.Loc.PC, proc.NextBreakpoint, nil)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"error setting breakpoint inside deferreturn\")\n\t\t\t\t}\n\t\t\t\tdynCallback := func(th proc.Thread, tgt *proc.Target) (bool, error) {\n\t\t\t\t\t// TODO(optimization): Consider using an iterator to avoid materializing\n\t\t\t\t\t// the full stack when we only need frames up to the root function\n\t\t\t\t\trawlocs, err := proc.ThreadStacktrace(tgt, tgt.CurrentThread(), followCalls+2)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn false, fmt.Errorf(\"thread stack trace returned error\")\n\t\t\t\t\t}","sourceCodeStart":1437,"sourceCodeEnd":1473,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/debugger/debugger.go#L1437-L1473","documentation":"Wrapped error from Debugger.traverse when proc.Disassemble cannot decode the instruction range [f.Entry, f.End) of a function being walked during follow-calls traversal. Disassembly is required to enumerate the call instructions of each function in the call graph; if the memory cannot be read or an instruction cannot be decoded, traversal aborts. The original disassembler error is preserved via %w.","triggerScenarios":"During Debugger.Functions(filter, followCalls>0): a matched function's body spans unreadable or non-executable memory (e.g. dynamically generated code, unmapped page in a core dump), or the backend's Memory() read fails mid-range, or the disassembler encounters bytes it cannot decode for the target architecture.","commonSituations":"Analyzing core dumps where the text page is not mapped; debugging stripped/obfuscated binaries with data embedded in text; JIT or assembly-heavy functions; architectures where golang.org/x/arch has partial coverage; remote/gdbserial targets with restricted memory reads.","solutions":["Inspect the wrapped %w error for the exact PC/decode failure.","Exclude the problematic function from the filter regex (e.g. narrow `main\\.` instead of `\\.`).","Use a smaller followCalls so fewer functions are disassembled.","Ensure the target memory is readable (process alive, core dump complete with all PT_LOAD segments).","Confirm the binary/architecture is supported by Delve (dlv backend support list)."],"exampleFix":"// before\nfuncs, err := client.Functions(\"main|runtime|internal/poll\", 10)\n// after\nfuncs, err := client.Functions(\"main\", 3) // exclude runtime/asm-heavy packages","handlingStrategy":"try-catch","validationCode":"// ensure the target is alive and the backend can read memory before follow-calls\nstate, err := client.GetState()\nif err != nil || state.Exited {\n    return fmt.Errorf(\"target not traceable: %v\", err)\n}","typeGuard":"var disasmErr *proc.ErrUnknownInstruction // or check wrapped cause\nif errors.As(err, &disasmErr) {\n    log.Printf(\"undecodable instruction at %#x\", disasmErr.PC)\n}","tryCatchPattern":"funcs, err := client.Functions(filter, followCalls)\nif err != nil && strings.Contains(err.Error(), \"disassemble failed\") {\n    // retry without deep traversal\n    funcs, err = client.Functions(filter, 0)\n}","preventionTips":["Use filters that avoid assembly/runtime packages (runtime.*, internal/bytealg).","Verify the binary is not stripped and the architecture is Delve-supported.","For core dumps, confirm all text PT_LOAD segments are present.","Keep followCalls small so fewer functions get disassembled.","Log the unwrapped inner error to identify the exact failing PC."],"tags":["debugger","disassembly","follow-calls","memory-read"],"backgroundTag":"disassembly-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}