mirror of
https://github.com/python/cpython.git
synced 2025-09-14 04:37:29 +00:00
Fix a crasher where Python code managed to infinitely recurse in C code without
ever going back out to Python code in PyObject_Call(). Required introducing a static RuntimeError instance so that normalizing an exception there is no reliance on a recursive call that would put the exception system over the recursion check itself.
This commit is contained in:
parent
68a6da99e6
commit
1e534b5425
11 changed files with 66 additions and 49 deletions
|
@ -132,6 +132,7 @@ PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
|
|||
PyObject *value = *val;
|
||||
PyObject *inclass = NULL;
|
||||
PyObject *initial_tb = NULL;
|
||||
PyThreadState *tstate = NULL;
|
||||
|
||||
if (type == NULL) {
|
||||
/* There was no exception, so nothing to do. */
|
||||
|
@ -207,7 +208,14 @@ finally:
|
|||
Py_DECREF(initial_tb);
|
||||
}
|
||||
/* normalize recursively */
|
||||
tstate = PyThreadState_GET();
|
||||
if (++tstate->recursion_depth > Py_GetRecursionLimit()) {
|
||||
--tstate->recursion_depth;
|
||||
PyErr_SetObject(PyExc_RuntimeError, PyExc_RecursionErrorInst);
|
||||
return;
|
||||
}
|
||||
PyErr_NormalizeException(exc, val, tb);
|
||||
--tstate->recursion_depth;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue