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:
“Personal size and mental sorrow have certainly no necessary proportions. A large bulky figure has a good a right to be in deep affliction, as the most graceful set of limbs in the world. But, fair or not fair, there are unbecoming conjunctions, which reason will pa tronize in vain,which taste cannot tolerate,which ridicule will seize.”
—Jane Austen (17751817)
“Vast chain of Being, which from God began,
Natures aethereal, human, angel, man,
Beast, bird, fish, insect! what no eye can see,
No glass can reach; from Infinite to thee,
From thee to Nothing!”
—Alexander Pope (16881744)