A common mistake among programmers is not providing a way to exit a recursive function, lettingoften itby runomitting infinitely.or Thisincorrectly ischecking calledthe ''infinitebase recursion''.case, Ifletting youit don'trun provide(at aleast waytheoretically) toinfinitely exitby theendlessly function,calling ititself willrecursively. goThis onis makingcalled recursive''infinite calls foreverrecursion'', and the program will never terminate. This is a very badIn ideapractice, sincethis ittypically willexhausts eatthe up theavailable [[Stack (abstract data type)|stack]] space. In most programming environments, a program with an infinite recursion will not really run forever. Eventually, something will break and the program will report an error.<ref>{{Cite web |title=4.8. Infinite Recursion |url=https://runestone.academy/ns/books/published/thinkcpp/Chapter4/InfiniteRecursion.html}}</ref>
Below is a Java code that would use infinite recursion:<syntaxhighlight lang="java" line="1">public class InfiniteRecursion {
Line 871:
recursive(); // Executes the recursive function upon runtime
}
}</syntaxhighlight> Running this code will giveresult youin a [[stack overflow]] error.