go-delve/delve · error

not enough stack space

Error message

not enough stack space

What it means

Delve throws this when a function call injection (e.g. `call f()` in the debugger) cannot be started because the goroutine's stack does not have enough spare room to run the call. Injected calls need contiguous free stack below the current frame; Delve checks the stack bounds before injection and refuses if the free space is below a safe threshold. This protects the target process from a stack overflow caused by the debugger itself.

Source

Thrown at pkg/proc/fncall.go:64

//  - evalCallInjectionComplete
//
// When the target has runtime.debugPinner then evalCallInjectionPinPointer
// must be also called in a loop until it returns false.

const (
	debugCallFunctionNamePrefix1 = "debugCall"
	debugCallFunctionNamePrefix2 = "runtime.debugCall"
	maxDebugCallVersion          = 2
	maxArgFrameSize              = 65535
)

var (
	errFuncCallUnsupported        = errors.New("function calls not supported by this version of Go")
	errFuncCallUnsupportedBackend = errors.New("backend does not support function calls")
	errFuncCallInProgress         = errors.New("cannot call function while another function call is already in progress")
	errNoGoroutine                = errors.New("no goroutine selected")
	errGoroutineNotRunning        = errors.New("selected goroutine not running")
	errNotEnoughStack             = errors.New("not enough stack space")
	errTooManyArguments           = errors.New("too many arguments")
	errNotEnoughArguments         = errors.New("not enough arguments")
	errNotAGoFunction             = errors.New("not a Go function")
	errFuncCallNotAllowedStrAlloc = errors.New("literal string can not be allocated because function calls are not allowed without using 'call'")
)

type functionCallState struct {
	// savedRegs contains the saved registers
	savedRegs Registers
	// err contains a saved error
	err error
	// expr is the expression being evaluated
	expr *ast.CallExpr
	// fn is the function that is being called
	fn *Function
	// receiver is the receiver argument for the function
	receiver *Variable
	// closureAddr is the address of the closure being called

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Select or switch to a goroutine with more free stack before issuing the call (e.g. frame 0 of a shallow goroutine)
  2. Use `print`/`frame` evaluation instead of `call` so no injection is needed
  3. Increase the target's stack headroom (larger initial goroutine stack / less recursion) or restructure the deep call chain
  4. Upgrade Go/Delve: stack-growth handling for injected calls has improved across versions

Example fix

// before (deep recursion, call fails)
(dlv) call fmt.Sprintf("%d", n)
// after: switch to a shallow frame/goroutine first
(dlv) goroutine 1
(dlv) call fmt.Sprintf("%d", n)
Defensive patterns

Strategy: validation

Validate before calling

// at the dlv prompt, before the call:
// (dlv) frame 0  -- pick a shallow frame
// (dlv) goroutine <id> -- pick a goroutine with room; then use call
// programmatically: check the goroutine's stack extent before injecting
func stackOK(g *proc.G) bool { return g != nil && g.CurrentLoc != (proc.Location{}) }

Prevention

When it happens

Trigger: Running `call <fn>(...)` (or an expression needing a hidden call like string allocation) on a goroutine whose current frame is near the top of a nearly-full stack, e.g. deep recursion; calling a function with many arguments or large argument area on a small stack.

Common situations: Debugging code with deep recursion and issuing a call; calling functions in goroutines with tiny stacks; evaluating expressions in a terminal breakpoint set at the deepest recursion level.

Related errors


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