[Python-checkins] CVS: python/dist/src/Python ceval.c,2.290,2.291

Tim Peters tim_one@users.sourceforge.net
2001年11月27日 15:29:31 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv13534/python/Python
Modified Files:
	ceval.c 
Log Message:
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.
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.290
retrieving revision 2.291
diff -C2 -d -r2.290 -r2.291
*** ceval.c	2001年11月20日 15:17:25	2.290
--- ceval.c	2001年11月27日 23:29:29	2.291
***************
*** 2561,2565 ****
--- 2561,2573 ----
 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;
 }

AltStyle によって変換されたページ (->オリジナル) /