{"record":{"id":"de093ca0f16450f1","repo":"go-delve/delve","slug":"internal-debugger-error-depth-check-error-at-inst","errorCode":null,"errorMessage":"internal debugger error: depth check error at instruction %d: expected depth %d have %d (jump target)\n%s","messagePattern":"internal debugger error: depth check error at instruction (.+?): expected depth (.+?) have (.+?) \\(jump target\\)\n(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/evalop/evalcompile.go","lineNumber":259,"sourceCode":"// checks that they have enough arguments to execute. For instructions that\n// can be reached through multiple paths (because of a jump) it checks that\n// all paths reach the instruction with the same stack depth.\n// Finally it checks that the stack depth after all instructions have\n// executed is equal to endDepth.\nfunc (ctx *compileCtx) depthCheck(endDepth int) error {\n\tdepth := make([]int, len(ctx.ops)+1) // depth[i] is the depth of the stack before i-th instruction\n\tfor i := range depth {\n\t\tdepth[i] = -1\n\t}\n\tdepth[0] = 0\n\n\tvar err error\n\tcheckAndSet := func(j, d int) { // sets depth[j] to d after checking that we can\n\t\tif depth[j] < 0 {\n\t\t\tdepth[j] = d\n\t\t}\n\t\tif d != depth[j] {\n\t\t\terr = fmt.Errorf(\"internal debugger error: depth check error at instruction %d: expected depth %d have %d (jump target)\\n%s\", j, d, depth[j], Listing(depth, ctx.ops))\n\t\t}\n\t}\n\n\tdebugPinnerSeen := false\n\n\tfor i, op := range ctx.ops {\n\t\tnpop, npush := op.depthCheck()\n\t\tif depth[i] < npop {\n\t\t\treturn fmt.Errorf(\"internal debugger error: depth check error at instruction %d: expected at least %d have %d\\n%s\", i, npop, depth[i], Listing(depth, ctx.ops))\n\t\t}\n\t\td := depth[i] - npop + npush\n\t\tcheckAndSet(i+1, d)\n\t\tswitch op := op.(type) {\n\t\tcase *Jump:\n\t\t\tcheckAndSet(op.Target, d)\n\t\tcase *CallInjectionStartSpecial:\n\t\t\tdebugPinnerSeen = true\n\t\tcase *CallInjectionComplete:","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/evalop/evalcompile.go#L241-L277","documentation":"An internal consistency check in Delve's expression-VM compiler (pkg/proc/evalop/evalcompile.go) failed: when computing operand-stack depths, a jump target instruction was reached with a different stack depth than previously recorded. This is a compiler invariant violation, not something caused by a syntactically valid user expression; it indicates a bug in Delve's opcode generation or a genuinely malformed generated program.","triggerScenarios":"Calling CompileAST or CompileSet on an expression whose compiled op sequence contains a Jump whose target's depth does not match the depth flowing into it — i.e. a Delve bug in evalop compilation, possibly triggered by an unusual expression shape that hits an untested compiler path.","commonSituations":"Rare; typically seen after a delve version regression, when testing experimental expression features (e.g. delve.catch, call injection combined with control flow), or when a breakpoint condition exercises a newly added opcode combination.","solutions":["Update to the latest delve release — check for known fixed issues around evalop/depthCheck","Simplify the expression (remove nesting, casts, calls) until it evaluates, then file a bug with the minimal reproducing expression and `Listing` output embedded in the error","Temporarily replace the failing breakpoint condition with a simpler one and inspect state manually"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := evalExpr(userExpr)\nif err != nil && strings.HasPrefix(err.Error(), \"internal debugger error\") {\n    // not a user mistake: simplify or report\n    out, err = evalExpr(simplify(userExpr))\n    log.Printf(\"delve internal error, please report: %v\", err)\n}","preventionTips":["Keep delve updated; internal invariant errors are compiler bugs fixed upstream","Avoid exotic combinations (calls + control flow) in breakpoint conditions until validated","Capture the full error (it embeds the instruction Listing) when filing a bug"],"tags":["debugger","internal","compiler","stack-depth","evalop"],"backgroundTag":"internal-invariant-violation","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}