diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-11-27 23:29:29 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-11-27 23:29:29 (GMT) |
commit | b13680bf034ee2522a9252127065100e5ca1c13f (patch) | |
tree | 6411f4100f0e187d784d29e89351b8f6d693b64b | |
parent | 6d20b43a4e3255e4b4fe4468861abf72166d9acf (diff) | |
download | cpython-b13680bf034ee2522a9252127065100e5ca1c13f.zip cpython-b13680bf034ee2522a9252127065100e5ca1c13f.tar.gz cpython-b13680bf034ee2522a9252127065100e5ca1c13f.tar.bz2 |
SF bug #483469: crash on unbounded recursion in __del__.
PyEval_EvalCodeEx(): increment tstate->recursion_depth around the
decref of the frame, because the C stack for this call is still in
use and the decref can lead to __del__ methods getting called.
While this gives tstate->recursion_depth a value proportional to the
depth of the C stack (instead of a small constant no matter how
deeply __del__s recurse), it's not enough to stop the reported crash
when using the default recursion limit on Windows.
Bugfix candidate.
-rw-r--r-- | Python/ceval.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 21ee3db..fd602b0 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2560,7 +2560,15 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, fail: /* Jump here from prelude on failure */ + /* decref'ing the frame can cause __del__ methods to get invoked, + which can call back into Python. While we're done with the + current Python frame (f), the associated C stack is still in use, + so recursion_depth must be boosted for the duration. + */ + assert(tstate != NULL); + ++tstate->recursion_depth; Py_DECREF(f); + --tstate->recursion_depth; return retval; } |