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:
“Women hock their jewels and their husbands insurance policies to acquire an unaccustomed shade in hair or crêpe de chine. Why then is it that when anyone commits anything novel in the arts he should be always greeted by this same peevish howl of pain and surprise? One is led to suspect that the interest people show in these much talked of commodities, painting, music, and writing, cannot be very deep or very genuine when they so wince under an unexpected impact.”
—John Dos Passos (18961970)
“The consciousness in each man is a sliding scale, which identifies him now with the First Cause, and now with the flesh of his body; life above life, in infinite degrees.”
—Ralph Waldo Emerson (18031882)