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:
“In the great and deep qualities of mind, heart, and soul, there is no change. Homer and Solomon speak to the same nature in man that is reached by Shakespeare and Lincoln. but in the accidents, the surroundings, the change is vast. All things now are mobilemovable.”
—Rutherford Birchard Hayes (18221893)
“Moreover, the universe as a whole is infinite, for whatever is limited has an outermost edge to limit it, and such an edge is defined by something beyond. Since the universe has no edge, it has no limit; and since it lacks a limit, it is infinite and unbounded. Moreover, the universe is infinite both in the number of its atoms and in the extent of its void.”
—Epicurus (c. 341271 B.C.)