Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecursionError on pathological input #270

Open
Google-Autofuzz opened this issue Nov 2, 2020 · 2 comments
Open

RecursionError on pathological input #270

Google-Autofuzz opened this issue Nov 2, 2020 · 2 comments

Comments

@Google-Autofuzz
Copy link

Google-Autofuzz commented Nov 2, 2020

When passing the attached input to the following script, I get an unexpected RecursionError exception, while using the latest git version of simplejson.

import sys
import simplejson

with open(sys.argv[1], 'rb') as f:
    data = f.read()
try:
    simplejson.dumps(simplejson.loads(data))
except simplejson.errors.JSONDecodeError:
    pass
except UnicodeDecodeError:
    pass
$ python simplejson_repro.py test.txt
Traceback (most recent call last):
  File "simplejson_repro.py", line 7, in <module>
    simplejson.dumps(simplejson.loads(data))
  File "/home/user/ven/lib/python3.8/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/home/user/ven/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/home/user/ven/lib/python3.8/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
RecursionError: maximum recursion depth exceeded while decoding a JSON object from a unicode string

test.txt

@serhiy-storchaka
Copy link
Contributor

Try ti increse the recursion limit by sys.setrecursionlimit().

@Google-Autofuzz
Copy link
Author

This won't solve the problem, since it's always doable to generate an sufficenlty large input to hit the recursion limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants