-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Eval with too high string multiplication crashes newer Python versions #86775
Comments
For Python version 3.7 and above the following statement will end up in a segfault. eval("1 + 100"*1000000) Whereas Python versions 3.6 and below would tread this as a Recursion error. |
In python 3.7/8, It's a stack overflow in the constant folding code. On master, the overflow seems to come out of validate_expr.c.
300,000 ish stack frames of this:
On the one hand, pure python code should never segfault, on the other hand, |
This is known issue, but interesting that the cause of the crash is different in 3.7-3.8 and 3.9+. PR 23744 adds recursion checks in the AST validator and optimizer similar to the checks in the symtable. It should not break any existing code because too deep AST tree did not pass checks in the symtable in any case. But it does not solve all problems. A compound statement with too many "elif"s is still crashed because the new parser uses recursion in C to parse it (elif_stmt_rule). I think it should be a separate issue. |
Apart from the 3.9 backport this is complete. |
Python 3.9 is security fix only now so closing. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: