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:

    Perhaps one reason that many working parents do not agitate for collective reform, such as more governmental or corporate child care, is that the parents fear, deep down, that to share responsibility for child rearing is to abdicate it.
    Faye J. Crosby (20th century)

    In a symbol there is concealment and yet revelation: here therefore, by silence and by speech acting together, comes a double significance.... In the symbol proper, what we can call a symbol, there is ever, more or less distinctly and directly, some embodiment and revelation of the Infinite; the Infinite is made to blend itself with the Finite, to stand visible, and as it were, attainable there. By symbols, accordingly, is man guided and commanded, made happy, made wretched.
    Thomas Carlyle (1795–1881)