diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-03-13 19:25:20 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-03-13 19:25:20 (GMT) |
commit | 652e7076fee59d92d19a0d6e326b9069a2aa09e4 (patch) | |
tree | 5287ec21422abfbe642d9ff2138cebac2ac04a00 /Include | |
parent | ae2dbe2543859f9ad0ff0a2e84b33421c8fd5406 (diff) | |
download | cpython-652e7076fee59d92d19a0d6e326b9069a2aa09e4.zip cpython-652e7076fee59d92d19a0d6e326b9069a2aa09e4.tar.gz cpython-652e7076fee59d92d19a0d6e326b9069a2aa09e4.tar.bz2 |
Issue #5392: when a very low recursion limit was set, the interpreter would
abort with a fatal error after the recursion limit was hit twice.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/ceval.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Include/ceval.h b/Include/ceval.h index 919c494..7bd8179 100644 --- a/Include/ceval.h +++ b/Include/ceval.h @@ -92,11 +92,10 @@ PyAPI_DATA(int) _Py_CheckRecursionLimit; # define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit) #endif -#ifdef USE_STACKCHECK -# define _Py_MakeEndRecCheck(x) (--(x) < _Py_CheckRecursionLimit - 50) -#else -# define _Py_MakeEndRecCheck(x) (--(x) < _Py_CheckRecursionLimit - 50) -#endif +#define _Py_MakeEndRecCheck(x) \ + (--(x) < ((_Py_CheckRecursionLimit > 100) \ + ? (_Py_CheckRecursionLimit - 50) \ + : (3 * (_Py_CheckRecursionLimit >> 2)))) #define Py_ALLOW_RECURSION \ do { unsigned char _old = PyThreadState_GET()->recursion_critical;\ |