go-delve/delve · error
could not get return values: %v
Error message
could not get return values: %v
What it means
Once the injected call returns, Delve builds a scope at the thread's current position to read return values. This error is raised when ThreadScope fails, i.e. the post-call frame could not be resolved, so the call's return values cannot be reported.
Source
Thrown at pkg/proc/fncall.go:896
// See https://github.com/go-delve/delve/issues/2985 and
// TestCallInjectionFlagCorruption
rflags := bi.Arch.RegistersToDwarfRegisters(0, fncall.savedRegs).Uint64Val(regnum.AMD64_Rflags)
err := thread.SetReg(regnum.AMD64_Rflags, op.DwarfRegisterFromUint64(rflags))
if err != nil {
fncall.err = fmt.Errorf("could not restore RFLAGS register: %v", err)
}
}
return true
case debugCallRegReadReturn: // 1
// read return arguments from stack
stack.callInjectionContinue = true
if fncall.panicvar != nil || fncall.err != nil {
break
}
retScope, err := ThreadScope(p, thread)
if err != nil {
fncall.err = fmt.Errorf("could not get return values: %v", err)
break
}
// pretend we are still inside the function we called
fakeFunctionEntryScope(retScope, fncall.fn, int64(regs.SP()), regs.SP()-uint64(bi.Arch.PtrSize()))
var flags localsFlags
flags |= localsNoDeclLineCheck | localsFakeFunctionEntryScope // if the function we are calling is an autogenerated stub then declaration lines have no meaning
if !bi.regabi {
flags |= localsTrustArgOrder
}
fncall.retvars, err = retScope.Locals(flags, "")
if err != nil {
fncall.err = fmt.Errorf("could not get return values: %v", err)
break
}
fncall.retvars = filterVariables(fncall.retvars, func(v *Variable) bool {
return (v.Flags & VariableReturnArgument) != 0View on GitHub (pinned to a23773e6c3)
Solutions
- Ensure the binary keeps full debug info (build without -ldflags '-s -w')
- Check whether the called function terminated the process (e.g. os.Exit) — that's a legitimate failure mode
- Retry the call at a different, symbolized stop location
- Upgrade Go/Delve if the return frame is in runtime code with bad info
Defensive patterns
Strategy: validation
Validate before calling
// Build with full debug info so the return frame resolves: // go build -gcflags="all=-N -l" -o app . # no -s -w stripping
Try / catch
err := dbg.CallFunction(scope, fn, args)
if err != nil && strings.Contains(err.Error(), "could not get return values") {
// return frame unresolvable: retry or inspect state manually
}
Prevention
- Never strip DWARF from binaries you debug
- Avoid calling functions that exit or panic the process
- Stop at symbolized user code before injecting calls
- Upgrade toolchain if the return frame sits in runtime code
When it happens
Trigger: funcCallStep in debugCallRegReadReturn (1), with no panic or earlier error, calls ThreadScope(p, thread) and it fails (symbolization failure at the return PC, dead thread, unreadable memory).
Common situations: Binary stripped of DWARF info; return PC lands in code without line info; process exited because the called function terminated it; optimized code confusing frame resolution.
Related errors
- no goroutine selected
- not implemented: %s
- could not get precheck error reason: %v
- %v
- could not restore registers: %v
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/41943d37777aeefa.
Report an issue: GitHub.