Skip to main content

Try it Live

Run Bytecode examples in the interactive playground

    StackAnalysis Type

    StackIssue

    BlockStackInfo

    Options

    Usage Patterns

    Basic Validation

    Detect Underflows

    Detect Overflows

    Block-Level Requirements

    Path Analysis

    Custom Initial Depth

    Useful for analyzing contract fragments:

    Stack Effects

    Each opcode has a defined stack effect:

    Stack Input/Output

    • ADD: 2 inputs, 1 output (effect: -1)
    • PUSH1: 0 inputs, 1 output (effect: +1)
    • DUP1: 1 input, 2 outputs (effect: +1)
    • SWAP1: 2 inputs, 2 outputs (effect: 0)
    • POP: 1 input, 0 outputs (effect: -1)
    Stack effects come from Opcode.getStackEffect().

    Cumulative Tracking

    EVM Stack Limits

    Depth Limit (1024)

    EVM enforces a maximum stack depth of 1024 items:

    DUP/SWAP Limits

    • DUP1-DUP16: Requires 1-16 items on stack
    • SWAP1-SWAP16: Requires 2-17 items on stack

    Integration with Opcode Module

    Stack effects from Opcode module:

    Common Issues

    Underflow Patterns

    Inconsistent Paths

    Limitations

    Stack analysis is based on static control flow and cannot account for:
    • Dynamic jump targets - Cannot determine all possible JUMPI destinations
    • External calls - Callee’s stack effects unknown
    • Recursive calls - Unbounded stack growth
    • Inline assembly - Non-standard stack manipulation
    Results represent possible issues, not guaranteed runtime behavior.

    What’s Validated

    ✅ Stack underflows (popping from empty stack) ✅ Stack overflows (exceeding 1024 limit) ✅ Block entry requirements ✅ DUP/SWAP validity ✅ Path consistency (where determinable)

    What’s Not Validated

    ❌ Dynamic jump target validity ❌ External call effects ❌ Loop iteration counts ❌ Recursion depth

    Error Handling

    Optimization Hints

    Identify inefficient stack patterns:

    See Also