{"record":{"id":"8c3c1c40f2bd1ec0","repo":"go-delve/delve","slug":"errstackindexoutofbounds","errorCode":"ErrStackIndexOutOfBounds","errorMessage":"DWARF stack index out of bounds","messagePattern":"DWARF stack index out of bounds","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/dwarf/op/op.go","lineNumber":54,"sourceCode":"type Piece struct {\n\tSize  int\n\tKind  PieceKind\n\tVal   uint64\n\tBytes []byte\n}\n\n// PieceKind describes the kind of a piece.\ntype PieceKind uint8\n\nconst (\n\tAddrPiece PieceKind = iota // The piece is stored in memory, Val is the address\n\tRegPiece                   // The piece is stored in a register, Val is the register number\n\tImmPiece                   // The piece is an immediate value, Val or Bytes is the value\n)\n\nvar (\n\tErrStackUnderflow        = errors.New(\"DWARF stack underflow\")\n\tErrStackIndexOutOfBounds = errors.New(\"DWARF stack index out of bounds\")\n\tErrMemoryReadUnavailable = errors.New(\"memory read unavailable\")\n)\n\nconst arbitraryExecutionLimitFactor = 10\n\n// ExecuteStackProgram executes a DWARF location expression and returns\n// either an address (int64), or a slice of Pieces for location expressions\n// that don't evaluate to an address (such as register and composite expressions).\nfunc ExecuteStackProgram(regs DwarfRegisters, instructions []byte, ptrSize int, readMemory ReadMemoryFunc) (int64, []Piece, error) {\n\tctxt := &context{\n\t\tbuf:            bytes.NewBuffer(instructions),\n\t\tprog:           instructions,\n\t\tstack:          make([]int64, 0, 3),\n\t\tDwarfRegisters: regs,\n\t\tptrSize:        ptrSize,\n\t\treadMemory:     readMemory,\n\t}\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/dwarf/op/op.go#L36-L72","documentation":"ErrStackIndexOutOfBounds is a sentinel error returned when a DWARF expression opcode references a stack slot that does not exist, e.g. the pick opcode addressing beyond the current stack depth. Like ErrStackUnderflow it is defined as a public sentinel in pkg/dwarf/op and propagated by ExecuteStackProgram.","triggerScenarios":"Executing a DWARF expression containing a pick opcode with an index equal to or greater than the number of values currently on the expression stack.","commonSituations":"Badly generated DWARF (compiler bug), corrupted debug sections, or reusing/patching expressions that no longer match the emitted stack layout.","solutions":["Recompile the target binary with a current toolchain to regenerate valid DWARF","Validate that the pick index in the expression is < current stack depth before executing custom expressions","Treat the variable/expression as unreadable when errors.Is(err, op.ErrStackIndexOutOfBounds)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-check pick depth if you generate expressions yourself\nif pickIndex >= currentStackDepth { return errors.New(\"pick index exceeds stack depth\") }","typeGuard":null,"tryCatchPattern":"if errors.Is(err, op.ErrStackIndexOutOfBounds) { /* treat as unreadable expression */ }","preventionTips":["Validate generated DWARF expression streams against a linter/dumper","Rebuild binaries when DWARF parse errors appear","Avoid patching expression bytes in place"],"tags":["dwarf","stack-index","expression-evaluation"],"backgroundTag":"dwarf-stack-underflow","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}