If you don't know what while(true){} bug is, go to jsbin.com and type it.
There is no good solution so far...
If you don't know what while(true){} bug is, go to jsbin.com and type it.
There is no good solution so far...
(Of course, that'll slow the code down a lot.)
The question is, what is a desirable solution?
It's easy enough to detect while(true){}, but it's impossible to detect longer equivalent pieces of code.
I'd be fine with a "pause/halt running js" button; unfortunately, it's up to the browser to provide. User-provided solutions are essentially guaranteed to cause horrible slowdown.
We solved the while(true){} by limiting the number of instructions the javascript program can run. To do this we use Rhino which is a Javascript implementation which runs in the JVM. It provides us a hook to get the instruction count.
We had to figure this out, since we let our customers run their own scripts on our network. If they write a script that never terminates, then they've hosed a machine on our network.
An old tool I used would insert a check at the end of each loop for if the escape key was being pressed and exit