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

Compiler RecursionError more likely to occur in 3.13 #120331

Open
williamwen42 opened this issue Jun 10, 2024 · 1 comment
Open

Compiler RecursionError more likely to occur in 3.13 #120331

williamwen42 opened this issue Jun 10, 2024 · 1 comment
Labels
topic-parser type-bug An unexpected behavior, bug, or error

Comments

@williamwen42
Copy link
Contributor

williamwen42 commented Jun 10, 2024

Bug report

Bug description:

Reference: sympy/sympy#26692

There's a long expression in sympy that's causing a RecursionError in ast.c. The source of the RecursionError is

PyErr_SetString(PyExc_RecursionError,
.

This seems to happen with a 3.13 debug build due to a lower recursion limit. The error doesn't happen in 3.13 release.

Interestingly, the error doesn't happen in the 3.12 debug build, even though the recursion limit appears to be the same. This leads me to believe that 3.13 is causing more recursive calls than expected. I think we should investigate why 3.13 is making additional calls and/or raise the recursion limit.

Simple repro:

import ast
contents = "x = " + " * ".join(["1"] * 2000)
result = ast.parse(contents)

On 3.12 debug, this code runs fine. On 3.13 debug, this code causes a RecursionError even when we change 2000 to 500 (leading me to believe that it is not the case that 3.13 is just adding a constant number of additional calls).

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

Linux

@williamwen42 williamwen42 added the type-bug An unexpected behavior, bug, or error label Jun 10, 2024
@williamwen42
Copy link
Contributor Author

Recursion limit set here

# define Py_C_RECURSION_LIMIT 500
for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-parser type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants