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:
“Whoever knows he is deep tries to be clear, but whoever wants to seem deep to the crowd tries to be obscure. For the crowd supposes that anything it cannot see to the bottom must be deep: it is so timid and goes so unwillingly into the water.”
—Friedrich Nietzsche (18441900)
“This is the monstruosity in love, ladythat the will is infinite and the execution confined; that the desire is boundless and the act a slave to limit.”
—William Shakespeare (15641616)