{"record":{"id":"43af5eea0959f8ad","repo":"go-delve/delve","slug":"could-not-get-precheck-error-reason-v","errorCode":null,"errorMessage":"could not get precheck error reason: %v","messagePattern":"could not get precheck error reason: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/fncall.go","lineNumber":849,"sourceCode":"\t\t\t\tfnname = loc.Fn.Name\n\t\t\t}\n\t\t}\n\t\tfncallLog(\"function call interrupt gid=%d (original) thread=%d regval=%#x (PC=%#x in %s %s:%d)\", callScope.g.ID, thread.ThreadID(), regval, pc, fnname, loc.File, loc.Line)\n\t}\n\n\tswitch regval {\n\tcase debugCallRegPrecheckFailed: // 8\n\t\tstack.callInjectionContinue = true\n\t\tarchoff := uint64(0)\n\t\tif bi.Arch.Name == \"arm64\" || bi.Arch.Name == \"loong64\" {\n\t\t\tarchoff = 8\n\t\t} else if bi.Arch.Name == \"ppc64le\" {\n\t\t\tarchoff = 40\n\t\t}\n\t\t// get error from top of the stack and return it to user\n\t\terrvar, err := readStackVariable(p, thread, regs, archoff, \"string\", LoadFullValue())\n\t\tif err != nil {\n\t\t\tfncall.err = fmt.Errorf(\"could not get precheck error reason: %v\", err)\n\t\t\tbreak\n\t\t}\n\t\terrvar.Name = \"err\"\n\t\tfncall.err = fmt.Errorf(\"%v\", constant.StringVal(errvar.Value))\n\n\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}","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/fncall.go#L831-L867","documentation":"During the debugCallV2 protocol, the Go runtime writes a human-readable reason string on the stack when it must abort an injected call. Delve failed to read that stack variable (of type 'string'), so it wraps the read failure with this message instead of the underlying runtime reason. The actual function-call error is then hidden behind this diagnostic.","triggerScenarios":"funcCallStep receives debugCallRegCheckPrecondition/other failure status from the runtime, and readStackVariable fails while reading the 'string' reason variable from the top of the stack (bad stack pointer, unreadable memory, missing registers).","commonSituations":"Attaching to a stripped or foreign binary whose DWARF for the debug-call stubs is missing; process memory unreadable because the target crashed mid-protocol; architecture offset mismatches (archoff) on ppc64le/arm64/amd64.","solutions":["Retry the 'call' command — transient memory-read failures often succeed on a second attempt","Check the target process is alive and not already crashed","Ensure the binary has full debug info (not stripped)","Upgrade Delve and/or Go: protocol offsets changed between versions"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Before 'call', confirm the target is stoppable and readable:\n// dlv: state, err := dbg.ProcessState(); check state.Exited == false\n// and that the binary is not stripped: file <binary> | grep 'not stripped'","typeGuard":null,"tryCatchPattern":"err := dbg.CallFunction(scope, fn, args)\nif err != nil && strings.Contains(err.Error(), \"could not get precheck error reason\") {\n\t// retry once after confirming process alive\n}\n","preventionTips":["Use non-stripped binaries so the debug-call stub variables are visible","Match Delve version to the target Go version (protocol offsets change)","Ensure the process is alive before injecting calls","Retry transient stack-read failures once"],"tags":["go","fncall","stack-read","debugger"],"backgroundTag":"fncall-runtime-reason-unreadable","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}