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:
“Direct me gods, whose changes are all holy,
To where it flickers deep in grass, the moly:”
—Thom Gunn (b. 1929)
“Whatever we have got has been by infinite labour, and search, and ranging through every corner of nature; the difference is that instead of dirt and poison, we have rather chosen to fill our hives with honey and wax, thus furnishing mankind with the two noblest of things, which are sweetness and light.”
—Jonathan Swift (16671745)