]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Put method-wrappers into trashcan. Fixes #927248.
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 3 Jul 2006 13:47:29 +0000 (13:47 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 3 Jul 2006 13:47:29 +0000 (13:47 +0000)
Lib/test/test_descr.py
Misc/NEWS
Objects/descrobject.c

index ed779db2eea5d8b05fda66ede6cc76ce4efb230e..4fb3b5269b54b99f89e96f7dd0a45657adf61ac8 100644 (file)
@@ -3936,6 +3936,13 @@ def weakref_segfault():
     o.whatever = Provoker(o)
     del o
 
+def wrapper_segfault():
+    # SF 927248: deeply nested wrappers could cause stack overflow
+    f = lambda:None
+    for i in xrange(1000000):
+        f = f.__call__
+    f = None
+
 # Fix SF #762455, segfault when sys.stdout is changed in getattr
 def filefault():
     if verbose:
@@ -4075,6 +4082,7 @@ def notimplemented():
 
 def test_main():
     weakref_segfault() # Must be first, somehow
+    wrapper_segfault()
     do_this_first()
     class_docstrings()
     lists()
index a1c3cde58c4085666270b3df3c6f0438640d7c9e..87d5ac24da4f90cdbc7fdaacafba98192e96a93e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.4.4c1?
 Core and builtins
 -----------------
 
+- Bug #927248: Recursive method-wrapper objects can now safely
+  be released.
+
 - Bug #992017: A classic class that defined a __coerce__() method that returned
   its arguments swapped would infinitely recurse and segfault the interpreter.
 
index 7d523cf2014c87742afa0af6c26ea4b4150f3166..d12145d4bcb6ac89ddc730672885f95b6f4bd281 100644 (file)
@@ -904,10 +904,12 @@ typedef struct {
 static void
 wrapper_dealloc(wrapperobject *wp)
 {
-       _PyObject_GC_UNTRACK(wp);
+       PyObject_GC_UnTrack(wp);
+       Py_TRASHCAN_SAFE_BEGIN(wp)
        Py_XDECREF(wp->descr);
        Py_XDECREF(wp->self);
        PyObject_GC_Del(wp);
+       Py_TRASHCAN_SAFE_END(wp)
 }
 
 static PyMethodDef wrapper_methods[] = {