{"record":{"id":"ce53cb14b9533a0d","repo":"go-delve/delve","slug":"frame-d-does-not-exist-in-goroutine-d-ce53cb","errorCode":null,"errorMessage":"Frame %d does not exist in goroutine %d","messagePattern":"Frame (.+?) does not exist in goroutine (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/command.go","lineNumber":2548,"sourceCode":"\t\tstate, err := t.client.GetState()\n\t\tif err != nil {\n\t\t\treturn \"\", 0, false, err\n\t\t}\n\t\tif showContext {\n\t\t\tprintcontext(t, state)\n\t\t}\n\t\tif state.SelectedGoroutine != nil {\n\t\t\treturn state.SelectedGoroutine.CurrentLoc.File, state.SelectedGoroutine.CurrentLoc.Line, true, nil\n\t\t}\n\t\treturn state.CurrentThread.File, state.CurrentThread.Line, true, nil\n\n\tcase len(args) == 0 && ctx.scoped():\n\t\tlocs, err := t.client.Stacktrace(ctx.Scope.GoroutineID, ctx.Scope.Frame, ctx.Scope.Frame, 0, nil)\n\t\tif err != nil {\n\t\t\treturn \"\", 0, false, err\n\t\t}\n\t\tif len(locs) == 0 {\n\t\t\treturn \"\", 0, false, fmt.Errorf(\"Frame %d does not exist in goroutine %d\", ctx.Scope.Frame, ctx.Scope.GoroutineID)\n\t\t}\n\t\tloc := locs[0]\n\t\tgid := ctx.Scope.GoroutineID\n\t\tif gid < 0 {\n\t\t\tstate, err := t.client.GetState()\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", 0, false, err\n\t\t\t}\n\t\t\tif state.SelectedGoroutine != nil {\n\t\t\t\tgid = state.SelectedGoroutine.ID\n\t\t\t}\n\t\t}\n\t\tif showContext {\n\t\t\tfmt.Fprintf(t.stdout, \"Goroutine %d frame %d at %s:%d (PC: %#x)\\n\", gid, ctx.Scope.Frame, loc.File, loc.Line, loc.PC)\n\t\t}\n\t\treturn loc.File, loc.Line, true, nil\n\n\tdefault:","sourceCodeStart":2530,"sourceCodeEnd":2566,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/command.go#L2530-L2566","documentation":"In Delve's terminal client, the `frame`/`scope`-dependent command calls the RPC Stacktrace for the current goroutine and frame. If the returned stack is empty, the requested frame index does not exist (frames are 0-indexed and bounded by the actual call depth), so the command fails with this message.","triggerScenarios":"Running a terminal command that resolves the current scope (e.g. printing/disassembly helpers) when ctx.Scope.Frame points beyond the goroutine's stack depth — typically after selecting a frame number larger than the stack, or after the stack shrank (unwound/deeper frames gone) while the frame index was still set.","commonSituations":"Typing `frame 20` or `up` repeatedly past the top of the stack, then running a command like `print` or `disass` that uses the scoped location; resuming execution in one terminal while another command still references an old deep frame.","solutions":["Run `frames` (or `stack`) to see how many frames exist and pick a valid index","Use `frame 0` to reset to the topmost frame","Re-run `continue`/`step` so the scope refreshes, then retry the command"],"exampleFix":"// before (in a script against dlv)\nframe 12\nprint x\n// after\nframes\nframe 3\nprint x","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"locs, err := client.Stacktrace(gid, 0, 100, 0, nil)\nif err != nil { return err }\nif ctx.Frame >= len(locs) {\n    return fmt.Errorf(\"frame %d out of range: goroutine %d has %d frames\", ctx.Frame, gid, len(locs))\n}","preventionTips":["Check stack depth before dereferencing a frame index in tooling"],"tags":["terminal","stacktrace","cli"],"backgroundTag":"frame-out-of-range","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}