| Previous | Next |
| ERROR_SWAPERROR | ERROR_INVALID_MESSAGE |
ERROR_STACK_OVERFLOW
recursion too deep; the stack overflowed.
ERROR_STACK_OVERFLOW means that a thread exhausted the committed space available for its call stack.
Where the result appears
- unbounded or unexpectedly deep recursion.
- large automatic arrays or structures allocated on the stack.
- mutual recursion in parsers, visitors, serializers, or tree walkers.
- callbacks or hooks that re-enter the same code path without a guard.
Typical causes
- input depth is not bounded before recursive processing.
- a termination condition is missing or based on corrupted state.
- stack usage per frame became excessive after a code or compiler change.
- the thread was created with a stack reserve too small for the legitimate workload.
What to collect
- the deepest repeating call-stack pattern and the input that produced it.
- thread stack reserve/commit settings and architecture.
- sizes of local variables, compiler options, and recent changes to frame layout.
- whether the failure is deterministic at a particular nesting depth.
Handling and recovery
Fix the algorithm or frame size before considering a larger stack. Convert recursive traversal to an explicit work stack where untrusted input can control depth, and enforce documented limits. A larger reserve can be appropriate only after measuring legitimate worst-case depth and its effect on process address space.
Common misinterpretation
Catching the resulting exception and continuing on the same exhausted stack is unsafe. Recovery normally requires unwinding to a protected boundary or terminating the affected operation.
References
Looking for a different code? Search another status or error code.