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:

    When the weather is bad as it was yesterday, everybody, almost everybody, feels cross and gloomy. Our thin linen tents—about like a fish seine, the deep mud, the irregular mails, the never to-be-seen paymasters, and “the rest of mankind,” are growled about in “old-soldier” style. But a fine day like today has turned out brightens and cheers us all. We people in camp are merely big children, wayward and changeable.
    Rutherford Birchard Hayes (1822–1893)

    i thank You God for most this amazing
    day: for the leaping greenly spirits of trees
    and a blue true dream of sky; and for everything
    which is natural which is infinite which is yes
    —E.E. (Edward Estlin)