{"record":{"id":"3f54ee28c58794f1","repo":"go-delve/delve","slug":"could-not-find-function-at-x","errorCode":null,"errorMessage":"could not find function at %#x","messagePattern":"could not find function at %#x","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/stack.go","lineNumber":1057,"sourceCode":"\t}\n\treturn d\n}\n\n// EvalScope returns an EvalScope relative to the argument frame of this deferred call.\n// The argument frame of a deferred call is stored in memory immediately\n// after the deferred header.\nfunc (d *Defer) EvalScope(t *Target, thread Thread) (*EvalScope, error) {\n\tscope, err := GoroutineScope(t, thread)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not get scope: %v\", err)\n\t}\n\n\tbi := thread.BinInfo()\n\tscope.PC = d.DwrapPC\n\tscope.File, scope.Line, scope.Fn = bi.PCToLine(d.DwrapPC)\n\n\tif scope.Fn == nil {\n\t\treturn nil, fmt.Errorf(\"could not find function at %#x\", d.DwrapPC)\n\t}\n\n\t// The arguments are stored immediately after the defer header struct, i.e.\n\t// addr+sizeof(_defer).\n\n\tif !bi.Arch.usesLR {\n\t\t// On architectures that don't have a link register CFA is always the address of the first\n\t\t// argument, that's what we use for the value of CFA.\n\t\t// For SP we use CFA minus the size of one pointer because that would be\n\t\t// the space occupied by pushing the return address on the stack during the\n\t\t// CALL.\n\t\tscope.Regs.CFA = (int64(d.variable.Addr) + d.variable.RealType.Common().ByteSize)\n\t\tscope.Regs.Reg(scope.Regs.SPRegNum).Uint64Val = uint64(scope.Regs.CFA - int64(bi.Arch.PtrSize()))\n\t} else {\n\t\t// On architectures that have a link register CFA and SP have the same\n\t\t// value but the address of the first argument is at CFA+ptrSize so we set\n\t\t// CFA to the start of the argument frame minus one pointer size.\n\t\tscope.Regs.CFA = int64(d.variable.Addr) + d.variable.RealType.Common().ByteSize - int64(bi.Arch.PtrSize())","sourceCodeStart":1039,"sourceCodeEnd":1075,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/stack.go#L1039-L1075","documentation":"Defer.EvalScope sets scope.PC to d.DwrapPC (the PC inside the deferred wrapper function) and resolves it to a function via PCToLine. If no function is found at that address, Delve refuses to build the scope since symbolization of the defer's target failed. Indicates stale or invalid DwrapPC, or missing symbol info.","triggerScenarios":"Calling Defer.EvalScope where d.DwrapPC doesn't map to any known function — defer records created by a different/older binary, corrupted _defer structs, or binary info loaded without the function containing DwrapPC (stripped/mismatched binary).","commonSituations":"Attached to a process running a different build than the binary Delve loaded; Go runtime version changes altering dwrap layout; corrupted memory reads of the defer chain.","solutions":["Verify the binary loaded in Delve exactly matches the running process (same build/paths)","Re-attach or restart the debug session to refresh defer records","Rebuild the target with full symbols","Update Delve; defer/dwrap parsing changes across Go versions"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"fn := bi.PCToFunction(dwrapPC); if fn == nil { return errors.New(\"defer dwrap PC not in loaded binary: binary mismatch\") }","typeGuard":"func deferResolvable(bi *proc.BinaryInfo, d *proc.Defer) bool { fn, _, _ := bi.PCToLine(d.DwrapPC); return fn != nil }","tryCatchPattern":"scope, err := d.EvalScope(t, thread); if err != nil && strings.Contains(err.Error(), \"could not find function at\") { /* flag binary/process mismatch and resync */ }","preventionTips":["Ensure Delve loads the exact binary the process executes","Do not rebuild the binary while attached","Keep Delve updated for Go-version-specific defer (dwrap) handling","Validate defer chains look sane before scope evaluation"],"tags":["go","defer","symbols","evalscope"],"backgroundTag":"pc-to-function-not-found","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}