[Python-bugs-list] [ python-Bugs-405583 ] Objects never freed with nested scopes
nobody
nobody@sourceforge.net
Mon, 12 Mar 2001 13:58:01 -0800
Bugs #405583, was updated on 2001-03-02 19:33
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=405583&group_id=5470
Category: Python Interpreter Core
Group: None
Status: Open
Priority: 7
Submitted By: Atsuo Ishimoto
Assigned to: Jeremy Hylton
Summary: Objects never freed with nested scopes
Initial Comment:
With this code,
from __future__ import nested_scopes
class foo:
def __del__(self): print "del foo"
def f1():
x = foo()
def f2():x
f2()
for i in range(10000):
f1()
I see no "del foo" message.
----------------------------------------------------------------------
Comment By: Jeremy Hylton
Date: 2001-03-12 13:58
Message:
Logged In: YES
user_id=31392
The patch from Martin seems correct, but does not resolve
the bug
report. There are still no __del__ calls.
----------------------------------------------------------------------
Comment By: Martin v. Löwis
Date: 2001-03-04 10:08
Message:
Logged In: YES
user_id=21627
I believe there are two missing decrefs: In STORE_DEREF,
PyCell_Set will incref the object, so the object POPped from
the stack must be decref'ed. In addition, GC requires that
the clear procedure not only sets the pointers to zero, but
actually decrefs the objects (i.e. breaks the cycle). A
patch is included below
Index: Objects/cellobject.c
===================================================================
RCS file:
/cvsroot/python/python/dist/src/Objects/cellobject.c,v
retrieving revision 1.1
diff -u -r1.1 cellobject.c
--- Objects/cellobject.c 2001/01/25 20:04:14 1.1
+++ Objects/cellobject.c 2001/03/04 18:04:45
@@ -83,6 +83,7 @@
static int
cell_clear(PyCellObject *op)
{
+ Py_XDECREF(op->ob_ref);
op->ob_ref = NULL;
return 0;
}
Index: Python/ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.230
diff -u -r2.230 ceval.c
--- Python/ceval.c 2001/02/16 11:52:31 2.230
+++ Python/ceval.c 2001/03/04 18:04:49
@@ -1670,6 +1670,7 @@
w = POP();
x = freevars[oparg];
PyCell_Set(x, w);
+ Py_DECREF(w);
continue;
case BUILD_TUPLE:
----------------------------------------------------------------------
Comment By: Fred L. Drake, Jr.
Date: 2001-03-03 09:34
Message:
Logged In: YES
user_id=3066
Assigned to Jeremy Hylton.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=405583&group_id=5470