go-delve/delve · error

could not find function for %#v

Error message

could not find function for %#v

What it means

When loading a function-pointer/func value, Delve converts the target address to a function name via the binary info's PC-to-function map. If no function covers that address (fn == nil), the func value is marked unreadable.

Source

Thrown at pkg/proc/variables.go:1989

	if v.Unreadable != nil {
		return
	}
	if v.closureAddr == 0 {
		v.Base = 0
		v.Value = constant.MakeString("")
		return
	}

	val, err := readUintRaw(v.mem, v.closureAddr, int64(v.bi.Arch.PtrSize()))
	if err != nil {
		v.Unreadable = err
		return
	}

	v.Base = val
	fn := v.bi.PCToFunc(v.Base)
	if fn == nil {
		v.Unreadable = fmt.Errorf("could not find function for %#v", v.Base)
		return
	}

	v.Value = constant.MakeString(fn.Name)
	cst := fn.extra(v.bi).closureStructType
	v.Len = int64(len(cst.Field))

	if recurseLevel <= cfg.MaxVariableRecurse {
		v2 := v.newVariable("", v.closureAddr, cst, v.mem)
		v2.loadValueInternal(recurseLevel, cfg)
		v.Children = v2.Children
	}
}

// funcvalAddr reads the address of the funcval contained in a function variable.
func (v *Variable) funcvalAddr() uint64 {
	val, err := readUintRaw(v.mem, v.Addr, int64(v.bi.Arch.PtrSize()))
	if err != nil {

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Check whether the address belongs to C/assembly code: use 'disassemble' around the address or check with nm/objdump
  2. If cgo, note Delve can only name Go functions; inspect the raw address and resolve the C symbol externally
  3. Rebuild ensuring DWARF is emitted for all packages (no -w/-s flags)
  4. If the pointer should be a Go func, investigate corruption (print surrounding memory / use watchpoints)

Example fix

// before
print myFuncVar   // could not find function for 0x7f3a00102040 (C code addr)
// after: inspect address and resolve outside Delve
print *(*uintptr)(...)  // raw address
// then: nm mybinary | grep <addr>
Defensive patterns

Strategy: validation

Validate before calling

// Check the func target resolves before relying on the value
fn := bi.PCToFunc(addr)
if fn == nil { /* address is C/asm/invalid — resolve externally */ }

Try / catch

v, err := dbg.EvalVariable(scope, "fnVar", cfg)
if err == nil && v.Unreadable != nil && strings.Contains(v.Unreadable.Error(), "could not find function") {
    // fall back to raw address inspection
}

Prevention

When it happens

Trigger: Printing a func variable or interface containing a func whose code address has no DWARF function entry: pointers into cgo code, assembly stubs without symbols, trampolines, or garbage/corrupted function pointers.

Common situations: Inspecting func values wrapping C function pointers in cgo programs; debugging binaries stripped of symbol/DWARF function tables; corrupted func values from type confusion bugs.

Related errors


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