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:
“It is deep January. The sky is hard.
The stalks are firmly rooted in ice.”
—Wallace Stevens (18791955)
“Each man has his own vocation. The talent is the call. There is one direction in which all space is open to him. He has faculties silently inviting him thither to endless exertion. He is like a ship in the river; he runs against obstructions on every side but one; on that side all obstruction is taken away, and he sweeps serenely over a deepening channel into an infinite sea.”
—Ralph Waldo Emerson (18031882)