On Thu, Jul 2, 2009 at 7:25 PM, Marco
Schuster<marco(a)harddisk.is-a-geek.org> wrote:
On Fri, Jul 3, 2009 at 4:22 AM, Aryeh Gregor
<Simetrical+wikilist@gmail.com<Simetrical%2Bwikilist@gmail.com>
wrote:
> On Thu, Jul 2, 2009 at 10:18 PM, Steve Bennett<stevagewp(a)gmail.com
wrote:
> > So:
> > 1) The chosen language will support iteration over finite sets
> > 2) Could it support general iteration, recursion etc?
> > 3) If so, are there any good mechanisms for limiting the
> > destrutiveness of an infinite loop?
>
> You don't really need an infinite loop. DoS would work fine if you
> can have any loop. Even with just foreach:
>
> foreach(array(1,2)as $x1)foreach(array(1,2)as $x2)....
>
> A few dozen of those in a row will give you a nice short bit of code
> that may as well run forever.
>
You can make some kind of counter, which gets incremented each
foreach/while/for loop. If it reaches 200 (or whatever), execution is
stopped.
Really, the ideal solution is to say the user is allowed X number of
basic operations, Y amount of memory, and Z amount of execution time,
and write an interpreter that is agnostic about how those resources
are used. If all you do is add limits to loops, then someone will add
loops of loops and or even flat stacks to get around it.
-Robert Rohde