I can see the newsflash now: CodePen.io, an online social web development sandbox service, has finally managed to solve what many computer scientists have deemed unsolvable.

This is actually a bit misleading. A general solution to the halting problem does not exist and is therefore unsolvable; Alan Turing proved this conclusively in 1936. But it is true that CodePen now offers better infinite loop detection.

Many cases of infinite loops can be detected through static analysis tools like Dafny. These types of tools rely on invariants, preconditions, postconditions, and assertions to ensure that a program is functionally correct. Alternatively, infinite loop detection can be simulated through code coverage tools and watchdogs during execution. These tools can find “hot-spots” where code is executed disproportionately often over a long period of time. This is often a red flag for an infinite loop and multithreaded programs use watchdogs like this to offer options for user intervention:

<img src="/assets/2015/01/chrome-infinite-loop.png" class="figure-img img-fluid rounded">

<figcaption class="figure-caption">

<p>Infinite loop intervention in Google Chrome</p>

</figcaption>