[Python-bugs-list] [ python-Bugs-485139 ] mem leak in interpreter from syntax err

noreply@sourceforge.net noreply@sourceforge.net
Fri, 07 Dec 2001 09:13:10 -0800


Bugs item #485139, was opened at 2001-11-24 10:45
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=485139&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2
>Status: Open
Resolution: Wont Fix
Priority: 7
Submitted By: Neal Norwitz (nnorwitz)
>Assigned to: Tim Peters (tim_one)
Summary: mem leak in interpreter from syntax err

Initial Comment:
when a syntax error occurs in the interpreter, the
interpreter leaks
see the attached file for more info

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

>Comment By: Tim Peters (tim_one)
Date: 2001-12-07 09:13

Message:
Logged In: YES 
user_id=31435

Reopened and assigned to me.  I don't care about a leak on 
an uncaught syntax error, but something Neal said reminded 
me of a problem that's repeatedly wasted my time:   "enter 
something at a debug-mode interactive prompt repeatedly" 
often exhibits "and lose a refcount each time" behavior.  
Like so:

>>> 1
1
[7026 refs]
>>> class C: pass
...
[7036 refs]
>>> class C: pass
...
[7037 refs]
>>> class C: pass
...
[7038 refs]
>>> class C: pass
...
[7039 refs]
>>>

Several times this has fooled me into looking for leaks 
that don't exist.

>>> def f(): pass
...
[7056 refs]
>>> def f(): pass
...
[7057 refs]
>>> def f(): pass
...
[7058 refs]
>>>

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-07 08:46

Message:
Logged In: YES 
user_id=6380

Neal writes:

---

I tried:

	for i in range(1000):
	  try:
	    import t2
	  except SyntaxError:
	    print

But that doesn't leak.  I think the reason it doesn't leak
is because 
of the try/except.  I opened the interpreter and
interactively
created syntax errors (=<return>, =<return>, ...) and it
leaked
for each error, not just once 874 bytes, instead of 38 for
1.

If there is a way to raise a syntax error without exitting
the interpreterr
I think it could blow up faster.

-----

My comment: if it only leaks when you don't catch it, that
doesn't bother me much, since that's the end of the process.
:-) So I'm closing this.

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

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

Message:
Logged In: YES 
user_id=6380

Neil, can you provide more evidence?  I can't see this leak
in a loop, like this:

| while 1:
|     try: compile("/", "", "exec")
|     except SyntaxError: pass


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

Comment By: Tim Peters (tim_one)
Date: 2001-11-27 12:05

Message:
Logged In: YES 
user_id=31435

Assigned to Barry.

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

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