[Python-bugs-list] [ python-Bugs-489671 ] memory leak in test_richcmp

noreply@sourceforge.net noreply@sourceforge.net
Thu, 06 Dec 2001 13:28:57 -0800


Bugs item #489671, was opened at 2001-12-05 18:44
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=489671&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
Assigned to: Guido van Rossum (gvanrossum)
Summary: memory leak in test_richcmp

Initial Comment:
leak when running test_richcmp

see attached file for details


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-06 13:28

Message:
Logged In: YES 
user_id=6380

Further boiled it down to this testcase:

| def bar(a):
|     a + (1/0)
| 
| while 1:
|     try:
|         bar([])
|     except:
|         pass

Apparently the stack is not cleared properly when an
exception happens with something on the stack.

[...]

After a debug session with Tim and some CVS digging, I
realized that in the pre-generators days, there was a little
loop clearing the stack after the /* main loop */ comment,
that's no longer there. Turns out in Neil's generators patch
had commented this code out, and the merge completely
removed it -- but it was needed and the proper solution is
to execute this code EXCEPT when yielding from a generator.
Much thanks to Tim for his help in finding this!

This is fixed in ceval.c 2.296.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-06 12:31

Message:
Logged In: YES 
user_id=6380

Boiled down to this test case:


| class C: # new-style class leaks too
| 
|     def foo(self):
|         (self, 1/0) # This leaks
|         1/0 # This doesn't
| 
| while 1:
|     a = C()
|     try:
|         a.foo() # This leaks
|         (a, 1/0) # This doesn't
|     except:
|         pass


----------------------------------------------------------------------

Comment By: Jeremy Hylton (jhylton)
Date: 2001-12-06 07:56

Message:
Logged In: YES 
user_id=31392

It's specifically the testvector() function that causes the
leak in test_richcmp.


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=489671&group_id=5470