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:

    The good enough mother, owing to her deep empathy with her infant, reflects in her face his feelings; this is why he sees himself in her face as if in a mirror and finds himself as he sees himself in her. The not good enough mother fails to reflect the infant’s feelings in her face because she is too preoccupied with her own concerns, such as her worries over whether she is doing right by her child, her anxiety that she might fail him.
    Bruno Bettelheim (20th century)

    His hair has the long jesuschrist look. He is wearing the costume clothes. But most of all, he now has a very tolerant and therefore withering attitude toward all those who are still struggling in the old activist political ways ... while he, with the help of psychedelic chemicals, is exploring the infinite regions of human consciousness.
    Tom Wolfe (b. 1931)