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:
“They that goe downe to th sea in ships:
Their busines there to doo
In waters great. The Lords work see,
Ith deep his wonders too.”
—Bible: Hebrew Psalm CVII (Bay Psalm Book)
“That mans best works should be such bungling imitations of Natures infinite perfection, matters not much; but that he should make himself an imitation, this is the fact which Nature moans over, and deprecates beseechingly. Be spontaneous, be truthful, be free, and thus be individuals! is the song she sings through warbling birds, and whispering pines, and roaring waves, and screeching winds.”
—Lydia M. Child (18021880)