{"record":{"id":"416829321eea3ee2","repo":"go-delve/delve","slug":"selected-goroutine-not-running","errorCode":null,"errorMessage":"selected goroutine not running","messagePattern":"selected goroutine not running","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/fncall.go","lineNumber":63,"sourceCode":"//  - evalCallInjectionCopyArg\n//  - 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","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/fncall.go#L45-L81","documentation":"errGoroutineNotRunning is returned by EvalExpressionWithCalls and evalCallInjectionStart when the selected goroutine exists but is not in the Running state; injected function calls can only be executed on a goroutine that is currently running on a thread and stopped at a safe point.","triggerScenarios":"Attempting a function call while the selected goroutine is blocked (chan receive, syscall, sleep) or parked; selecting a goroutine that is waiting rather than the one stopped at the breakpoint; 'call' issued after switching to a non-running goroutine.","commonSituations":"Switching to a goroutine blocked on I/O or channel ops and then trying 'call'; debugging a deadlocked program where no goroutine is running; picking the wrong goroutine ID after 'goroutines' listing.","solutions":["Select the goroutine that is currently stopped at the breakpoint (the one hit by the debugger) before issuing 'call'","Check the goroutine's status with 'goroutines' and only call on status Running","If the interesting goroutine is blocked, use breakpoints/variable inspection instead of injecting calls"],"exampleFix":"// before: goroutine 5 is blocked on a channel\ndlv> goroutine 5\ndlv> call foo(1)\n// after: use the running, stopped goroutine\ndlv> goroutine 1\ndlv> call foo(1)","handlingStrategy":"validation","validationCode":"// only call on a Running goroutine stopped at a breakpoint\n// dlv> goroutines   -- check status column is 'Running'\ndlv> goroutine <running-id>\ndlv> call foo(1)","typeGuard":null,"tryCatchPattern":"if errors.Is(err, proc.ErrGoroutineNotRunning) {\n    // re-select the goroutine stopped at the breakpoint and retry\n}","preventionTips":["Check the goroutine status field before issuing 'call'","Use the goroutine that hit the breakpoint (scope of the current stop) for calls","For blocked goroutines, prefer breakpoints and variable inspection over call injection"],"tags":["go","function-call","goroutine","state"],"backgroundTag":"goroutine-not-running","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}