bpo-11105: Do not crash when compiling recursive ASTs#20594
Conversation
When compiling an AST object with a direct / indirect reference cycles, on the conversion phase because of exceeding amount of calls, a segfault was raised. This patch adds recursion guards to places for preventing user inputs to not to crash AST but instead raise a RecursionError.
|
I didn't bother with benchmarking extensively though it seems like when compiling python AST objects (only on |
|
🤖 New build scheduled with the buildbot fleet by @isidentical for commit 9f8c68f 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
|
@isidentical could you run a quick benchmark to see if this has any effect on the general speed? I expect almost nothing, but is never bad to check |
What do you mean by general speed? This is the code path taken when the python level AST objects ( |
Sorry, I was on my phone and I missed #20594 (comment) 🤦 That was what I was searching for :) |
|
Thanks @isidentical for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.9. |
|
Sorry, @isidentical and @pablogsal, I could not cleanly backport this to |
|
GH-26521 is a backport of this pull request to the 3.10 branch. |
When compiling an AST object with a direct / indirect reference cycles, on the conversion phase because of exceeding amount of calls, a segfault was raised. This patch adds recursion guards to places for preventing user inputs to not to crash AST but instead raise a RecursionError. (cherry picked from commit f349124) Co-authored-by: Batuhan Taskaya <batuhan@python.org>
|
@isidentical Can you do the manual backport to 3.9? |
Yeah, sure! |
When compiling an AST object with a direct / indirect reference cycles, on the conversion phase because of exceeding amount of calls, a segfault was raised. This patch adds recursion guards to places for preventing user inputs to not to crash AST but instead raise a RecursionError. (cherry picked from commit f349124) Co-authored-by: Batuhan Taskaya <batuhan@python.org>
|
GH-26522 is a backport of this pull request to the 3.9 branch. |
…-20594) When compiling an AST object with a direct / indirect reference cycles, on the conversion phase because of exceeding amount of calls, a segfault was raised. This patch adds recursion guards to places for preventing user inputs to not to crash AST but instead raise a RecursionError.. (cherry picked from commit f349124) Co-authored-by: Batuhan Taskaya <batuhan@python.org>
GH-26522) When compiling an AST object with a direct / indirect reference cycles, on the conversion phase because of exceeding amount of calls, a segfault was raised. This patch adds recursion guards to places for preventing user inputs to not to crash AST but instead raise a RecursionError.. (cherry picked from commit f349124) Co-authored-by: Batuhan Taskaya <batuhan@python.org>
When compiling AST objects with direct or indirect reference cycles, the converter (python -> native) used to crash. Now it properly manages all the potential calls that might fall into a recursive state with
Py_EnterRecursiveCall/Py_LeaveRecursiveCall.https://bugs.python.org/issue11105