{"record":{"id":"4ec4b5abc82c8cfe","repo":"go-delve/delve","slug":"could-not-step-out-of-s-v","errorCode":null,"errorMessage":"could not step out of %s: %v","messagePattern":"could not step out of (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/fncall.go","lineNumber":873,"sourceCode":"\tcase debugCallRegCompleteCall: // 0\n\t\tp.fncallForG[callScope.g.ID].startThreadID = 0\n\n\tcase debugCallRegRestoreRegisters: // 16\n\t\t// runtime requests that we restore the registers (all except pc and sp),\n\t\t// this is also the last step of the function call protocol.\n\t\tpc, sp := regs.PC(), regs.SP()\n\t\tif err := thread.RestoreRegisters(fncall.savedRegs); err != nil {\n\t\t\tfncall.err = fmt.Errorf(\"could not restore registers: %v\", err)\n\t\t}\n\t\tif err := setPC(thread, pc); err != nil {\n\t\t\tfncall.err = fmt.Errorf(\"could not restore PC: %v\", err)\n\t\t}\n\t\tif err := setSP(thread, sp); err != nil {\n\t\t\tfncall.err = fmt.Errorf(\"could not restore SP: %v\", err)\n\t\t}\n\t\tfncallLog(\"stepping thread %d\", thread.ThreadID())\n\t\tif err := stepInstructionOut(callScope.callCtx.grp, p, thread, fncall.debugCallName, fncall.debugCallName); err != nil {\n\t\t\tfncall.err = fmt.Errorf(\"could not step out of %s: %v\", fncall.debugCallName, err)\n\t\t}\n\t\tif bi.Arch.Name == \"amd64\" {\n\t\t\t// The tail of debugCallV2 corrupts the state of RFLAGS, we must restore\n\t\t\t// it one extra time after stepping out of it.\n\t\t\t// See https://github.com/go-delve/delve/issues/2985 and\n\t\t\t// TestCallInjectionFlagCorruption\n\t\t\trflags := bi.Arch.RegistersToDwarfRegisters(0, fncall.savedRegs).Uint64Val(regnum.AMD64_Rflags)\n\t\t\terr := thread.SetReg(regnum.AMD64_Rflags, op.DwarfRegisterFromUint64(rflags))\n\t\t\tif err != nil {\n\t\t\t\tfncall.err = fmt.Errorf(\"could not restore RFLAGS register: %v\", err)\n\t\t\t}\n\t\t}\n\t\treturn true\n\n\tcase debugCallRegReadReturn: // 1\n\t\t// read return arguments from stack\n\t\tstack.callInjectionContinue = true\n\t\tif fncall.panicvar != nil || fncall.err != nil {","sourceCodeStart":855,"sourceCodeEnd":891,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/fncall.go#L855-L891","documentation":"Delve steps the thread out of runtime.debugCallV2 to leave the debug-call machinery cleanly. This error wraps any failure from stepInstructionOut, meaning the thread could not be single-stepped out of the debug-call stub.","triggerScenarios":"funcCallStep calls stepInstructionOut after restoring PC/SP and it returns an error (single-step breakpoint could not be set, thread stopped unexpectedly, step hit an unexpected breakpoint).","commonSituations":"Other breakpoints or watchpoints firing inside debugCallV2 while stepping out; process dying mid-step; concurrent modifications to breakpoints during the call; very old Go versions lacking debugCallV2 support.","solutions":["Clear other breakpoints on the debug-call frames or retry the call","Ensure the Go version of the target is recent enough (debugCallV2, Go 1.14+)","Restart the session if the thread is in an unknown state","Upgrade Delve to pick up fixes for stepping-out regressions"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Ensure a recent Go runtime (debugCallV2, Go 1.14+):\n// go version -m <binary>  -> confirm go1.14 or newer","typeGuard":null,"tryCatchPattern":"err := dbg.CallFunction(scope, fn, args)\nif err != nil && strings.Contains(err.Error(), \"could not step out\") {\n\t// clear other breakpoints, then retry once\n}\n","preventionTips":["Remove competing breakpoints near runtime.debugCallV2 before calling","Require Go 1.14+ for call injection support","Keep Delve current for step-out fixes","Retry the call after a transient step failure"],"tags":["go","fncall","single-step","debugger"],"backgroundTag":"fncall-step-out-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}