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:
“Im a scientist also, Dr. Holden. I know the value of the cold light of reason. But I also know the deep shadows that light can cast. The shadows that can blind men to truth.”
—Charles Bennett (b. 1899)
“He that will consider the infinite power, wisdom, and goodness of the Creator of all things, will find reason to think it was not all laid out upon so inconsiderable, mean, and impotent a creature as he will find man to be; who, in all probability, is one of the lowest of all intellectual beings.”
—John Locke (16321704)