[pypy-issue] Issue #2936: coredump generated when OOM in PYPY (pypy/pypy)
Weikang Jin
issues-reply at bitbucket.org
Wed Jan 2 22:45:44 EST 2019
New issue 2936: coredump generated when OOM in PYPY
https://bitbucket.org/pypy/pypy/issues/2936/coredump-generated-when-oom-in-pypy
Weikang Jin:
Python version: pypy-6.0.0-linux_x86_64-portable
Operating System: CentOS Linux release 7.6.1810
### CODE ###
```
#!python
from gevent import monkey
monkey.patch_all()
import bottle
from bottle import route, run
import sys, random, string
PYPY = hasattr(sys, 'pypy_version_info')
# test cpython
if not PYPY:
import resource
def limit_memory(maxsize):
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
resource.setrlimit(resource.RLIMIT_AS, (maxsize, hard))
limit_memory(200 * 1000 * 1000 * 2)
@route('/')
def index():
buf = []
for _ in range(1000):
buf.append(random.choice(string.letters) * 10**6)
return "ok"
if __name__ == "__main__":
run(host='localhost', port=8000)
else:
app = bottle.default_app()
```
### RUN ###
$ PYPY_GC_MIN=300MB PYPY_GC_MAX=400MB PYPYLOG=gc:- pypy app.py
$ http :8000
### LOG ###
[596869e8b3584] gc-collect-step}
return self.wsgi(environ, start_response)
File "/root/workspace/pypy-6.0.0-linux_x86_64-portable/site-packages/bottle.py", line 954, in wsgi
out = self._cast(self._handle(environ))
File "/root/workspace/pypy-6.0.0-linux_x86_64-portable/site-packages/bottle.py", line 862, in _handle
return route.call(**args)
File "/root/workspace/pypy-6.0.0-linux_x86_64-portable/site-packages/bottle.py", line 1740, in wrapper
rv = callback(*a, **ka)
File "app.py", line 22, in index
buf.append(random.choice(string.letters) * 10**6)
MemoryError
127.0.0.1 - - [03/Jan/2019 11:40:55] "GET / HTTP/1.1" 500 59
...
[5968a410c163e] gc-minor}
[5968a410c4338] {gc-collect-step
starting gc state: SWEEPING
[5968a4133cc50] {gc-collect-done
arenas: 12 => 12
bytes used in arenas: 5108344
bytes raw-malloced: 439381936 => 439382032
[5968a41350048] gc-collect-done}
RPython traceback:
File "pypy_interpreter_1.c", line 19837, in Method_descr_method_getattribute
File "pypy_interpreter.c", line 36849, in BuiltinCode2_fastcall_2
File "pypy_objspace.c", line 23854, in descr__getattribute__
using too much memory, aborting
[1] 2728 abort (core dumped) PYPY_GC_MIN=300MB PYPY_GC_MAX=400MB PYPYLOG=gc:- pypy app.py
MemoryError raised but the memory does not collect: bytes raw-malloced: 439381936 => 439382032
but cpython works expected, the processor is still alived and memory is normal state.
More information about the pypy-issue
mailing list