Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #3479

Re: An unusual question...

References <20110418105300.S4T3T.1176868.root@web11-winn.ispmail.private.ntl.com>
Date 2011-04-18 19:57 +1000
Subject Re: An unusual question...
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.508.1303120623.9059.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Apr 18, 2011 at 7:53 PM,  <wisecracker@tesco.net> wrote:
> Talking of nefarious usage...
>
> I wonder what this would do left unchecked on a current machine and current Python install...
>
> ###
>
> global somestring
> somestring = " "
>
> while 1:
>        #print somestring
>        somestring = somestring + " "
>
> ###

It'd take a while, but eventually bomb with MemoryError. If instead
you double the string's length with
"somestring=somestring+somestring", it'll bomb a lot quicker.

I know because I tried it. We have an isolation environment in which
we'll be allowing our clients to provide Python scripts - which means
we have to be sure it'll all be safe.

BTW, the point at which it bombs is defined by ulimit/rlimit, unless
you fiddle with the memory allocator. See previous thread on the
subject. :D

Chris Angelico

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: An unusual question... Chris Angelico <rosuav@gmail.com> - 2011-04-18 19:57 +1000

csiph-web