-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
stack overflow protection limit the max recursion depth when using custom frame evaluation #105003
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
Comments
The problem seems to come from the C recursion limit added in #91079 This explains why the behavior happens only after a depth of 800: cpython/Include/cpython/pystate.h Line 258 in 2c02c68
The custom frame eval function set by the perf trampoline indirectly decreases
|
Confirmed it's restricted by the C recursion limit. I think the correct thing here is to expose an API to change this. But this sound a little more, and may not be backported to 3.12? @markshannon @gpshead int py_recursion_remaining;
int py_recursion_limit;
int c_recursion_remaining;
+ int c_recursion_limit; |
It might still break some existing codebases that were using a custom eval function, limiting their recursion depth to 800 without AFAIK any possible workaround. |
Using a custom eval function and |
Yes totally. I wasn't very clear but I also managed to reproduce the issue with another dummy custom eval function like this: static PyObject * dummy_custom_evaluator(PyThreadState *ts, _PyInterpreterFrame *frame, int throw)
{
return _PyEval_EvalFrameDefault(ts, frame, throw);
} Thus for existing uses of the custom eval function, it might break existing implementations. |
I think we should just use this issue and remove the perf-specific part |
Is this the expected behavior from the stack overflow protection put in place in #91079? (cc @markshannon) I managed a dirty workaround incrementing the |
Bug report
Enabling the perf trampoline messes with the recursion limit.
Reproduction
The following execution works perfectly:
However, this gives a recursion error:
Strangely, the issue only arises when
n >= 801
and not under this value.@pablogsal if you have an idea of what could create the problem, I'd be happy to work on a fix!
Your environment
The text was updated successfully, but these errors were encountered: