This article describes a technique software that can employ to avoid entering an infinite-recursion loop when two or more software functions recursively call into each other. The specific technique avoids the infinite recursion scenario by employing an operating system daemon that performs automatic analysis of software call stacks and heuristically detects an infinite loop.
A way interfaces can interact avoiding an infinite loop
In certain software programs two or more functions call each other recursively to interact and generate output. In such a system, desired functionality can be regressed if something (internal or external) triggers a loop condition. One example of this exists in the IP network stack for tunnelling IPv4 via IPv6 and vice versa as seen here in the standard IP header field for specifying next protocol/header:
ipv4(next protocol=ipv6) ipv6(next protocol=ipv4)ipv4(next protocol=ipv6)... et. cetera.
Which can continue until the MTU of the link (e.g. ethernet 1500 bytes) is exhausted.
This type of scenario technically is not only limited to functional programs but also to object oriented programs in which interactions among objects can cause the current path of execution to enter in an infinite loop. Every time a function is called, parameters to the function can either be pushed into a register or through the stack but regardless of this the address of the actual function to be executed is pushed onto the stack. By taking advantage of this information a function can automatically analyze her current stack by obtaining the value of the stack pointer and reading backwards a predetermined amount of bytes. Because this information is inherently available prior to the function executing subsequent jumps, a simple comparison of stack return addresses can be utilized in combination...