-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Segmentation fault (stack overflow) due to unbounded recursion #1419
Comments
Good catch! There is also a similar issue related to The example you posted demonstrate another case of recursion. While I couldn't find an obvious recursive implementation in Re-writing an recursive implementation as a non-recursive is generally an improvement. However, there might be some considerations in revising these algorithms since they are fundamental part of the library. @nlohmann can give some insight on how to proceed. |
The recursive happens during deconstruction of array here. This recursion causes stack overflow for deeply nested arrays in JSON. The sanitizer crash log confirms this:
This pattern repeats for hundreds of lines. Full crash log is available here: https://pastebin.com/Ja0Se8iR |
Thanks for reporting! The parser itself is not recursive - the stack is modeled by a It would be great if we could find a better way for this. Or a way to detect the issue and throw an exception before it happens. The issue was already detected by Google's OSS Fuzz, see #832. There, I already asked for some opinions on how to proceed. I would mark this issue as duplicate and invite for a discussion in #832. |
Fixed by merging #1436. |
The following causes a segmentation fault (stack overflow) due to an apparent unbounded recursion.
The text was updated successfully, but these errors were encountered: