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:

    Suddenly, through birthing a daughter, a woman finds herself face to face not only with an infant, a little girl, a woman-to- be, but also with her own unresolved conflicts from the past and her hopes and dreams for the future.... As though experiencing an earthquake, mothers of daughters may find their lives shifted, their deep feelings unearthed, the balance struck in all relationships once again off kilter.
    Elizabeth Debold (20th century)

    The process of writing has something infinite about it. Even though it is interrupted each night, it is one single notation.
    Elias Canetti (b. 1905)