{"record":{"id":"41943d37777aeefa","repo":"go-delve/delve","slug":"could-not-get-return-values-v","errorCode":null,"errorMessage":"could not get return values: %v","messagePattern":"could not get return values: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/fncall.go","lineNumber":896,"sourceCode":"\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 {\n\t\t\tbreak\n\t\t}\n\t\tretScope, err := ThreadScope(p, thread)\n\t\tif err != nil {\n\t\t\tfncall.err = fmt.Errorf(\"could not get return values: %v\", err)\n\t\t\tbreak\n\t\t}\n\n\t\t// pretend we are still inside the function we called\n\t\tfakeFunctionEntryScope(retScope, fncall.fn, int64(regs.SP()), regs.SP()-uint64(bi.Arch.PtrSize()))\n\t\tvar flags localsFlags\n\t\tflags |= localsNoDeclLineCheck | localsFakeFunctionEntryScope // if the function we are calling is an autogenerated stub then declaration lines have no meaning\n\t\tif !bi.regabi {\n\t\t\tflags |= localsTrustArgOrder\n\t\t}\n\n\t\tfncall.retvars, err = retScope.Locals(flags, \"\")\n\t\tif err != nil {\n\t\t\tfncall.err = fmt.Errorf(\"could not get return values: %v\", err)\n\t\t\tbreak\n\t\t}\n\t\tfncall.retvars = filterVariables(fncall.retvars, func(v *Variable) bool {\n\t\t\treturn (v.Flags & VariableReturnArgument) != 0","sourceCodeStart":878,"sourceCodeEnd":914,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/fncall.go#L878-L914","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Build with full debug info so the return frame resolves:\n// go build -gcflags=\"all=-N -l\" -o app .   # no -s -w stripping","typeGuard":null,"tryCatchPattern":"err := dbg.CallFunction(scope, fn, args)\nif err != nil && strings.Contains(err.Error(), \"could not get return values\") {\n\t// return frame unresolvable: retry or inspect state manually\n}\n","preventionTips":["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"],"tags":["go","fncall","return-values","scope"],"backgroundTag":"fncall-return-value-read-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}