go-delve/delve · error

function %s not found

Error message

function %s not found

What it means

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.)

Source

Thrown at pkg/proc/fncall.go:1082

	if err != nil {
		return err
	}
	scope.Regs.FrameBase, _, _, _ = scope.BinInfo.Location(e, dwarf.AttrFrameBase, scope.PC, scope.Regs, nil)
	return nil
}

func (scope *EvalScope) callInjectionStartSpecial(stack *evalStack, op *evalop.CallInjectionStartSpecial, curthread Thread) bool {
	if op.ComplainAboutStringAlloc && scope.callCtx == nil {
		stack.err = errFuncCallNotAllowedStrAlloc
		return false
	}
	fnv, err := scope.findGlobalInternal(op.FnName)
	if fnv == nil {
		if err == nil {
			if op.ComplainAboutStringAlloc {
				err = errFuncCallNotAllowedStrAlloc
			} else {
				err = fmt.Errorf("function %s not found", op.FnName)
			}
		}
		stack.err = err
		return false
	}
	stack.push(fnv)
	scope.evalCallInjectionStart(&evalop.CallInjectionStart{HasFunc: true, Node: &ast.CallExpr{
		Fun:  &ast.Ident{Name: op.FnName},
		Args: op.ArgAst,
	}}, stack)
	if stack.err == nil {
		stack.pop() // return value of evalop.CallInjectionStart
		return true
	}
	return false
}

func (scope *EvalScope) convertAllocToString(stack *evalStack) {

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Rebuild the target with -gcflags="all=-N -l" (no optimization, no inlining) so runtime/leaf functions survive.
  2. Verify the function exists: use 'break <pkg>.<fn>' or 'functions' command to confirm the symbol is in the binary.
  3. Check Go version compatibility — the helper may have been renamed/removed; update Delve to match your Go version.
  4. Call a non-inlined wrapper function you control instead of the internal helper.
  5. If the error mentions string allocation, it is actually errFuncCallNotAllowedStrAlloc — allocate the string differently (e.g. build it before the breakpoint).

Example fix

// before
go build -o app ./cmd/app
dlv> call fmt.Sprintf("%d", x) // may be optimized/inlined away
// after
go build -gcflags="all=-N -l" -o app ./cmd/app
dlv> call fmt.Sprintf("%d", x)
Defensive patterns

Strategy: validation

Validate before calling

// confirm the symbol exists before calling it
dlv> functions fmt.Sprintf   // empty result -> symbol is inlined/absent
// programmatic: check binaryinfo for the function
fn := bi.FindFuncByName("main.helper")
if fn == nil { return fmt.Errorf("cannot inject: function not in binary") }

Type guard

func funcAvailable(bi *proc.BinaryInfo, name string) bool {
    return bi.FindFuncByName(name) != nil
}

Try / catch

if err != nil && strings.Contains(err.Error(), "not found") && strings.Contains(err.Error(), "function") {
    // symbol missing: rebuild unoptimized or pick a different (non-inlined) function
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/8fe40ded8384051e. Report an issue: GitHub.