Skip to main content
Definition Website Computer and Technology

Stack Overflow

Subject: Computer and Technology noun /ˈstæk ˈoʊ.vər.floʊ/ 1 definition

  1. Definition (noun)

    Entry #157 · Updated

    A Stack Overflow is a memory-exhaustion condition that occurs when a program attempts to push more data onto a call stack—or a fixed-capacity stack data structure—than its allocated boundary can hold. In typical process execution, each thread receives a fixed-size region of memory for its call stack, where stack frames storing return addresses, saved registers, and local variables are pushed on function entry and popped on return. Deep or unbounded recursion, oversized local stack allocations, or deeply nested interrupt handlers can drive the stack pointer past its reserved limit—often marked by an unmapped guard page—causing the operating system or language runtime to terminate execution with a hardware fault or exception. Unlike a stack-based buffer overflow, which overwrites adjacent data within existing frames by writing past a local array's bounds, a stack overflow exhausts the total space allocated to the stack itself.

    Common Types

    • Unbounded Recursion Overflow: Occurs when a recursive function lacks a reachable base case or recurses too deeply for the call stack budget, pushing frames continuously until stack space runs out.

    • Large Local Allocation Overflow: Arises when a function declares oversized local arrays or allocates large variable-length objects on the stack via mechanisms like alloca(), exhausting the remaining capacity in just a few calls.

    • Kernel and Interrupt Stack Overflow: Happens in operating system kernels or embedded firmware when deep driver call chains or nested hardware interrupts exceed small, fixed-size kernel stacks, often causing a kernel panic or reset.

    • Hardware and Data-Structure Stack Overflow: Occurs when a processor's fixed-depth hardware return stack or a bounded software stack receives a push operation while already at maximum capacity without dynamic resizing.

    Example

    When parsing a deeply nested JSON payload with 50,000 object levels, a recursive-descent parser in a Java service invokes parseObject() for each layer on a thread with a 1 MB call stack. Because each call pushes a new stack frame until the stack pointer exceeds the reserved limit, the JVM immediately halts the call chain by throwing a StackOverflowError.