mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
[3.12] GH-107263: Increase C stack limit for most functions, except _PyEval_EvalFrameDefault()
(GH-107535) (#107618)
GH-107263: Increase C stack limit for most functions, except `_PyEval_EvalFrameDefault()` (GH-107535)
* Set C recursion limit to 1500, set cost of eval loop to 2 frames, and compiler mutliply to 2.
(cherry picked from commit fa45958450
)
Co-authored-by: Mark Shannon <mark@hotpy.org>
This commit is contained in:
parent
58af2293c5
commit
98902d6c05
21 changed files with 57 additions and 45 deletions
|
@ -282,17 +282,10 @@ symtable_new(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* When compiling the use of C stack is probably going to be a lot
|
||||
lighter than when executing Python code but still can overflow
|
||||
and causing a Python crash if not checked (e.g. eval("()"*300000)).
|
||||
Using the current recursion limit for the compiler seems too
|
||||
restrictive (it caused at least one test to fail) so a factor is
|
||||
used to allow deeper recursion when compiling an expression.
|
||||
|
||||
Using a scaling factor means this should automatically adjust when
|
||||
/* Using a scaling factor means this should automatically adjust when
|
||||
the recursion limit is adjusted for small or large C stack allocations.
|
||||
*/
|
||||
#define COMPILER_STACK_FRAME_SCALE 3
|
||||
#define COMPILER_STACK_FRAME_SCALE 2
|
||||
|
||||
struct symtable *
|
||||
_PySymtable_Build(mod_ty mod, PyObject *filename, PyFutureFeatures *future)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue