Stack Overflow - Very Deep or Infinite Recursion

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 am sick of singing; the bays burn deep and chafe: I am fain
    To rest a little from praise and grievous pleasure and pain.
    —A.C. (Algernon Charles)

    Nothing could his enemies do but it rebounded to his infinite advantage,—that is, to the advantage of his cause.... No theatrical manager could have arranged things so wisely to give effect to his behavior and words. And who, think you, was the manager? Who placed the slave-woman and her child, whom he stooped to kiss for a symbol, between his prison and the gallows?
    Henry David Thoreau (1817–1862)