-
Notifications
You must be signed in to change notification settings - Fork 193
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
Deeply nested binary arithmetic segfaults under native parser #619
Comments
Hmmm, I can't reproduce this with the release build. |
Alright I can repro with 5000 (BTW the original parser works fine even with this many operators, but printing the tree fails with a |
Ah, I can also confirm. The parser itself is working fine (or giving a stack overflow) but the problem seems to be at
|
Looking at the core file, the bottleneck is not the parsing (strictly speaking), but the cloning of the excessively nested datastructure causing ~3500 stack frames. There are two things which we can do:
|
In CPython, that is exactly what we do. We hold an integer in the parser state, and increase it before each call (and check for the depth) and decrease it afterwards. |
#632 should help with any real world use cases. There's kevinmehall/rust-peg#282 open to address this in the parser framework. I'll see if I can hack something up in the meanwhile. |
Amazing, thank you @zsol! |
This is definietly not a realistic code (but it is still used in projects like this), though I think it might point to an underlying stack overflow or something like that (no experience in debugging rust applications, so unfortunately can't provide any more insight than this)
Here is the exampe payload:
Works perfectly with the python parser, but the native one crashes:
The text was updated successfully, but these errors were encountered: