{"record":{"id":"8fe40ded8384051e","repo":"go-delve/delve","slug":"function-s-not-found","errorCode":null,"errorMessage":"function %s not found","messagePattern":"function (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/fncall.go","lineNumber":1082,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\tscope.Regs.FrameBase, _, _, _ = scope.BinInfo.Location(e, dwarf.AttrFrameBase, scope.PC, scope.Regs, nil)\n\treturn nil\n}\n\nfunc (scope *EvalScope) callInjectionStartSpecial(stack *evalStack, op *evalop.CallInjectionStartSpecial, curthread Thread) bool {\n\tif op.ComplainAboutStringAlloc && scope.callCtx == nil {\n\t\tstack.err = errFuncCallNotAllowedStrAlloc\n\t\treturn false\n\t}\n\tfnv, err := scope.findGlobalInternal(op.FnName)\n\tif fnv == nil {\n\t\tif err == nil {\n\t\t\tif op.ComplainAboutStringAlloc {\n\t\t\t\terr = errFuncCallNotAllowedStrAlloc\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"function %s not found\", op.FnName)\n\t\t\t}\n\t\t}\n\t\tstack.err = err\n\t\treturn false\n\t}\n\tstack.push(fnv)\n\tscope.evalCallInjectionStart(&evalop.CallInjectionStart{HasFunc: true, Node: &ast.CallExpr{\n\t\tFun:  &ast.Ident{Name: op.FnName},\n\t\tArgs: op.ArgAst,\n\t}}, stack)\n\tif stack.err == nil {\n\t\tstack.pop() // return value of evalop.CallInjectionStart\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc (scope *EvalScope) convertAllocToString(stack *evalStack) {","sourceCodeStart":1064,"sourceCodeEnd":1100,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/fncall.go#L1064-L1100","documentation":"Special internal call injections (runtime steps like printing, string allocation hooks) look up the target function by name via scope.findGlobalInternal. If the lookup returns nil and no other error was set, Delve reports \"function %s not found\". This means the named function is not present in the binary's symbol table — usually because it was inlined, optimized out, dead-code eliminated, or belongs to a package not compiled into the binary. (If ComplainAboutStringAlloc is set, the string-allocation restriction error is reported instead.)","triggerScenarios":"callInjectionStartSpecial with op.FnName resolving to nil from findGlobalInternal: the function name doesn't exist in DWARF/symbol tables, e.g. calling runtime.printlock, runtime.concatstring2 or other internal helpers that are inlined or eliminated in the built binary; Delve internals (string comparison in variable loading) hitting a missing runtime helper.","commonSituations":"Binaries built with optimizations (-O / default go build without -gcflags=\"-N -l\") where runtime helpers are inlined; stripped binaries; version drift where the Go runtime renamed or removed a helper Delve expects; debugging external packages not linked into the target.","solutions":["Rebuild the target with -gcflags=\"all=-N -l\" (no optimization, no inlining) so runtime/leaf functions survive.","Verify the function exists: use 'break <pkg>.<fn>' or 'functions' command to confirm the symbol is in the binary.","Check Go version compatibility — the helper may have been renamed/removed; update Delve to match your Go version.","Call a non-inlined wrapper function you control instead of the internal helper.","If the error mentions string allocation, it is actually errFuncCallNotAllowedStrAlloc — allocate the string differently (e.g. build it before the breakpoint)."],"exampleFix":"// before\ngo build -o app ./cmd/app\ndlv> call fmt.Sprintf(\"%d\", x) // may be optimized/inlined away\n// after\ngo build -gcflags=\"all=-N -l\" -o app ./cmd/app\ndlv> call fmt.Sprintf(\"%d\", x)","handlingStrategy":"validation","validationCode":"// confirm the symbol exists before calling it\ndlv> functions fmt.Sprintf   // empty result -> symbol is inlined/absent\n// programmatic: check binaryinfo for the function\nfn := bi.FindFuncByName(\"main.helper\")\nif fn == nil { return fmt.Errorf(\"cannot inject: function not in binary\") }","typeGuard":"func funcAvailable(bi *proc.BinaryInfo, name string) bool {\n    return bi.FindFuncByName(name) != nil\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"not found\") && strings.Contains(err.Error(), \"function\") {\n    // symbol missing: rebuild unoptimized or pick a different (non-inlined) function\n}","preventionTips":["Build targets with -gcflags=\"all=-N -l\" for debug sessions needing call injection.","Verify with the 'functions'/'break' command that the symbol exists before calling.","Don't call tiny helpers likely to be inlined; write non-inlinable wrappers (//go:noinline).","Keep Go toolchain and Delve versions aligned — runtime helper names change.","For stripped binaries, keep a debug build with symbols for debugging."],"tags":["go","debugger","symbol-lookup","function-call-injection","dwarf"],"backgroundTag":"function-not-found","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}