{"record":{"id":"95825fdb9e824f31","repo":"go-delve/delve","slug":"not-enough-stack-space","errorCode":null,"errorMessage":"not enough stack space","messagePattern":"not enough stack space","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/fncall.go","lineNumber":64,"sourceCode":"//  - evalCallInjectionComplete\n//\n// When the target has runtime.debugPinner then evalCallInjectionPinPointer\n// must be also called in a loop until it returns false.\n\nconst (\n\tdebugCallFunctionNamePrefix1 = \"debugCall\"\n\tdebugCallFunctionNamePrefix2 = \"runtime.debugCall\"\n\tmaxDebugCallVersion          = 2\n\tmaxArgFrameSize              = 65535\n)\n\nvar (\n\terrFuncCallUnsupported        = errors.New(\"function calls not supported by this version of Go\")\n\terrFuncCallUnsupportedBackend = errors.New(\"backend does not support function calls\")\n\terrFuncCallInProgress         = errors.New(\"cannot call function while another function call is already in progress\")\n\terrNoGoroutine                = errors.New(\"no goroutine selected\")\n\terrGoroutineNotRunning        = errors.New(\"selected goroutine not running\")\n\terrNotEnoughStack             = errors.New(\"not enough stack space\")\n\terrTooManyArguments           = errors.New(\"too many arguments\")\n\terrNotEnoughArguments         = errors.New(\"not enough arguments\")\n\terrNotAGoFunction             = errors.New(\"not a Go function\")\n\terrFuncCallNotAllowedStrAlloc = errors.New(\"literal string can not be allocated because function calls are not allowed without using 'call'\")\n)\n\ntype functionCallState struct {\n\t// savedRegs contains the saved registers\n\tsavedRegs Registers\n\t// err contains a saved error\n\terr error\n\t// expr is the expression being evaluated\n\texpr *ast.CallExpr\n\t// fn is the function that is being called\n\tfn *Function\n\t// receiver is the receiver argument for the function\n\treceiver *Variable\n\t// closureAddr is the address of the closure being called","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/fncall.go#L46-L82","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Select or switch to a goroutine with more free stack before issuing the call (e.g. frame 0 of a shallow goroutine)","Use `print`/`frame` evaluation instead of `call` so no injection is needed","Increase the target's stack headroom (larger initial goroutine stack / less recursion) or restructure the deep call chain","Upgrade Go/Delve: stack-growth handling for injected calls has improved across versions"],"exampleFix":"// before (deep recursion, call fails)\n(dlv) call fmt.Sprintf(\"%d\", n)\n// after: switch to a shallow frame/goroutine first\n(dlv) goroutine 1\n(dlv) call fmt.Sprintf(\"%d\", n)","handlingStrategy":"validation","validationCode":"// at the dlv prompt, before the call:\n// (dlv) frame 0  -- pick a shallow frame\n// (dlv) goroutine <id> -- pick a goroutine with room; then use call\n// programmatically: check the goroutine's stack extent before injecting\nfunc stackOK(g *proc.G) bool { return g != nil && g.CurrentLoc != (proc.Location{}) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer print/frame evaluation over call in deep stacks","Switch to a shallow goroutine before injecting calls","Avoid call injection inside deeply recursive functions","Keep Delve and Go versions current for better stack handling"],"tags":["debugger","function-call-injection","stack-overflow"],"backgroundTag":"insufficient-stack-space-for-call-injection","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}