PyPy sandbox leaks when writing to stdout
Created originally on Bitbucket by kostialopuhin (Konstantin Lopukhin)
Here is etl.py:
#!python
import sys
def main():
for i in xrange(100000):
sys.stdout.write('%d\n' % i)
if __name__ == '__main__':
main()
I run it like this:
sandbox $ /usr/bin/time -l ./pypy_interact.py --tmp=. ../goal/pypy-c /tmp/etl.py > /dev/null
'import site' failed
6.50 real 5.33 user 1.56 sys
422952960 maximum resident set size
...
A slighly more complex example (that also reads from stdin) leaks twice as much:
gen.py:
#!python
import sys
for i in xrange(100000):
sys.stdout.write('%d\n' % i)
etl.py
#!python
import sys
def main():
while True:
line = sys.stdin.readline()
if line:
line = line.strip()
sys.stdout.write('%d\n' % (int(line) + 1,))
else:
break
if __name__ == '__main__':
main()
Run:
sandbox $ python gen.py | /usr/bin/time -l ./pypy_interact.py --tmp=. ../goal/pypy-c /tmp/etl.py > /dev/null
'import site' failed
14.69 real 12.35 user 3.20 sys
835825664 maximum resident set size
Version was built from 2.3.1 release:
sandbox $ ./pypy_interact.py ../goal/pypy-c
'import site' failed
Python 2.7.6 (32f35069a16d819b58c1b6efb17c44e3e53397b2, Jul 11 2014, 13:35:07)
[PyPy 2.3.1 with GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>>