[issue12017] Decoding a highly-nested object with json (_speedups enabled) causes segfault

Ezio Melotti report at bugs.python.org
Fri May 6 18:11:02 CEST 2011


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

Attached patch fixes the issues. The patch includes 6 tests that caused a segfault and that now raise a "RuntimeError: maximum recursion depth exceeded" error, matching the behavior of the Python version.

The recursion happen because scan_once_str/unicode might call _parse_object_str/unicode (for objects/dicts) and _parse_array_str/unicode (for arrays/lists), and these functions might call scan_once_str again for their inner elements.
To fix the problem I added Py_Enter/LeaveRecursiveCall around the calls to _parse_object_str and _parse_array_str in scan_once_str/unicode.

For some reason the message raised with json.loads('{"a":' * 100000 + '1' + '}' * 100000), is a generic "maximum recursion depth exceeded while calling a Python object", but that's probably not too important.
The other messages work fine.

----------
keywords: +patch
nosy: +benjamin.peterson, georg.brandl
priority: high -> release blocker
stage: needs patch -> commit review
Added file: http://bugs.python.org/file21911/issue12017.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12017>
_______________________________________


More information about the Python-bugs-list mailing list