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:
“I think of the nestling fallen into the deep grass,
The turtle gasping in the dusty rubble of the highway,
The paralytic stunned in the tub, and the water rising,
All things innocent, hapless, forsaken.”
—Theodore Roethke (19081963)
“So that if you would form a just judgment of what is of infinite importance to you not to be misled in,namely, in what degree of real merit you stand ... call in religion and morality.Look,What is written in the law of God?How readest thou?Consult calm reason and the unchangeable obligations of justice and truth;Mwhat say they?”
—Laurence Sterne (17131768)