[Python-bugs-list] [ python-Bugs-789402 ] Memory leak on open() only in 2.3?

SourceForge.net noreply at sourceforge.net
Mon Sep 15 14:30:18 EDT 2003


Bugs item #789402, was opened at 2003-08-15 13:23
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=789402&group_id=5470

Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: Fixed
Priority: 5
Submitted By: David Lambert (jdalambert)
Assigned to: Neal Norwitz (nnorwitz)
Summary: Memory leak on open() only in 2.3?

Initial Comment:




If  for instance /tmp is a directory, then the follwing

code fragment produces a large memory leak on Python

2.3 compiled on Linux 2.4.20. This does not appear to

be a problem with previous versions of the interpreter.





#!/usr/local/bin/python





while 1:

    try:

        open('/tmp')

    except:

        pass



It appears that the exception IOError: [Error 21] Is a

directory leave garbage. If the parameter to open()

does not exist, the problem does not occur.



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

>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-09-15 13:30

Message:
Logged In: YES 
user_id=80475

Did this fix get backported yet?

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

Comment By: Brett Cannon (bcannon)
Date: 2003-09-06 18:10

Message:
Logged In: YES 
user_id=357491

Maybe?  =)



I just did a quick check and PyErr_SetObject (in Python/errors.c) 

calls PyErr_Restore in the same file that uses the 'value' argument 

to set the current PyThreadState's curexc_value which holds a 

PyObject.



But there are so many places where PyThreadState is used I don't 

feel up to hunting down where it might cause an issue.  Perhaps 

with more knowledge of the exception framework can answer the 

question.

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

Comment By: David Lambert (jdalambert)
Date: 2003-08-19 15:17

Message:
Logged In: YES 
user_id=845425

Good point, but if PyObject_CallFunction fails, is

PyErr_SetObject safe with a NULL second parameter? 

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-08-19 14:12

Message:
Logged In: YES 
user_id=33168

Your fix is the same as what I checked in, except that I

used Py_XDECREF instead of Py_DECREF, since

PyObject_CallFunction could fail and return NULL.  This

still needs a test and backport to 2.3.1.

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

Comment By: David Lambert (jdalambert)
Date: 2003-08-19 08:52

Message:
Logged In: YES 
user_id=845425

Over the weekend and through Monday I ran my system 24/7

with the previously attached code. There do not seem to be

any problems, but I am waiting for your "blessing" before

considering it a fix.



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

Comment By: David Lambert (jdalambert)
Date: 2003-08-16 18:09

Message:
Logged In: YES 
user_id=845425

I think I may have a fix. Check out the attached file. It

seems to work for me.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-08-15 15:07

Message:
Logged In: YES 
user_id=33168

Wow, it sure does leak!



Checked in as:  Objects/fileobject.c 2.180



Still needs a test.  Leaving open until I get around to it.

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

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



More information about the Python-bugs-list mailing list