building an online judge to evaluate Python programs

Modulok modulok at gmail.com
Mon Sep 23 13:32:08 EDT 2013


>
>
> If you want to run untrusted Python code and prevent malice (or stupidity)
> from harming you, you need OS-level protection.
>
>
Agreed. Just for fun here's a simple example of what could be an honest
mistake
that consumes all physical memory and swap. A well behaved kernel will kill
the
process eventually when it can no longer allocate memory, but not before
bringing the machine to its knees:

    class Foo(object):
        def __init__(self):
            self.x = 1
        def __iter__(self):
            return self
        def next(self):
            self.x += 1
            # Oops. In a well behaved iterator this should eventually
            # raise 'StopIteration'. I knew I forgot something.


    a = Foo()
    b = list(a)


-Modulok-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130923/a0bcab9c/attachment.html>


More information about the Python-list mailing list