{"record":{"id":"aa6031be5af02bbb","repo":"go-delve/delve","slug":"empty-op-stack","errorCode":null,"errorMessage":"empty OP stack","messagePattern":"empty OP stack","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/dwarf/op/op.go","lineNumber":101,"sourceCode":"\t\tif !ok {\n\t\t\treturn 0, nil, fmt.Errorf(\"invalid instruction %#v\", opcode)\n\t\t}\n\n\t\terr = fn(opcode, ctxt)\n\t\tif err != nil {\n\t\t\treturn 0, nil, err\n\t\t}\n\t}\n\n\tif ctxt.pieces != nil {\n\t\tif len(ctxt.pieces) == 1 && ctxt.pieces[0].Kind == RegPiece {\n\t\t\treturn int64(regs.Uint64Val(ctxt.pieces[0].Val)), ctxt.pieces, nil\n\t\t}\n\t\treturn 0, ctxt.pieces, nil\n\t}\n\n\tif len(ctxt.stack) == 0 {\n\t\treturn 0, nil, errors.New(\"empty OP stack\")\n\t}\n\n\treturn ctxt.stack[len(ctxt.stack)-1], nil, nil\n}\n\n// PrettyPrint prints the DWARF stack program instructions to `out`.\nfunc PrettyPrint(out io.Writer, instructions []byte, regnumToName func(uint64) string) {\n\tin := bytes.NewBuffer(instructions)\n\n\tfor {\n\t\topcode, err := in.ReadByte()\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\top := Opcode(opcode)\n\t\tif name, hasname := opcodeName[op]; hasname {\n\t\t\tio.WriteString(out, name)\n\t\t\tif regnumToName != nil {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/dwarf/op/op.go#L83-L119","documentation":"A non-sentinel error created in ExecuteStackProgram when the DWARF expression finished without leaving any value on the stack, so there is no result to return. The function needs at least one final stack value to produce an address or confirm a piece list.","triggerScenarios":"op.ExecuteStackProgram executed an expression whose opcode stream consumed all stack values (e.g. ends with drop-like operations) or is effectively empty, leaving len(ctxt.stack)==0 at the end.","commonSituations":"Empty or truncated location attribute bytes in DWARF entries, expression streams mis-parsed due to wrong offset, or expressions designed for composite location results that the evaluator path does not expect.","solutions":["Inspect the DWARF attribute that produced the instruction bytes (objdump --dwarf=info) for emptiness or truncation","Recompile the binary to regenerate correct debug info","Guard the call site: treat an empty-result error as 'no location available' rather than retrying"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if len(instr) == 0 { return errors.New(\"no location expression\") }","typeGuard":null,"tryCatchPattern":"_, _, err := op.ExecuteStackProgram(...)\nif err != nil && strings.Contains(err.Error(), \"empty OP stack\") { /* no result value */ }","preventionTips":["Check that the DWARF attribute is non-empty before executing","Prefer higher-level variable evaluation APIs that handle empty locations"],"tags":["dwarf","empty-stack","expression-evaluation"],"backgroundTag":"dwarf-stack-underflow","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}