Very Deep or Infinite Recursion
The most common cause of stack overflow is excessively deep or infinite recursion. Languages like Scheme, which implement tail-call optimization, allow infinite recursion of a specific sort—tail recursion—to occur without stack overflow. This works because tail-recursion calls do not take up additional stack space.
An example of infinite recursion in C.
int foo { return foo; }The function foo, when it is invoked, continues to invoke itself, using additional space on the stack each time, until the stack overflows resulting in a segmentation fault.
Read more about this topic: Stack Overflow
Famous quotes containing the words deep and/or infinite:
“At great periods you have always felt, deep within you, the temptation to commit suicide. You gave yourself to it; breached your own defenses. You were a child. The idea of suicide was a protest against life; by dying, you would escape this longing for death.”
—Cesare Pavese (19081950)
“I would fain keep sober always; and there are infinite degrees of drunkenness.”
—Henry David Thoreau (18171862)