[pypy-issue] Issue #1833: PyPy sandbox leaks when writing to stdout (pypy/pypy)

Konstantin Lopuhin issues-reply at bitbucket.org
Fri Aug 1 11:25:39 CEST 2014


New issue 1833: PyPy sandbox leaks when writing to stdout
https://bitbucket.org/pypy/pypy/issue/1833/pypy-sandbox-leaks-when-writing-to-stdout

Konstantin Lopuhin:

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
```




More information about the pypy-issue mailing list