[Patches] [ python-Patches-669553 ] fix memory (ref) leaks
SourceForge.net
noreply@sourceforge.net
Sun, 19 Jan 2003 07:52:21 -0800
Patches item #669553, was opened at 2003-01-16 23:02
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=669553&group_id=5470
Category: None
Group: None
>Status: Closed
Resolution: Accepted
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
Assigned to: Neal Norwitz (nnorwitz)
Summary: fix memory (ref) leaks
Initial Comment:
Sorry, I'm lazy and this is a single patch to 2 files
to fix reference leaks.
The int patch can be demonstrated by doing:
abs(-2147483648)
The second happens when:
import pyexpat
p = pyexpat.ParserCreate()
p.__members__
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-01-19 10:52
Message:
Logged In: YES
user_id=33168
Raymond, you are correct about the problem in intobject. I
agree about that it could be cleaner to use PyList_New, but
I'm not making the change now. Just trying to make things
correct (and I'm too lazy :-).
Michael, these could be tested with pydebug builds, if
sys.getrefcount() was captured before and verified it was
correct after calling the code to test/exercise the
problems. I'm not sure it's worth it, though.
Checked in as:
intobject.c 2.99 and 2.79.6.6
pyexpat.c 2.77 and 2.57.6.5
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-18 22:00
Message:
Logged In: YES
user_id=80475
When the patches are fixed-up, they should also be
backported.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-18 19:04
Message:
Logged In: YES
user_id=80475
There is an error in the patch to intobject.c. When
o==NULL, then result is returned without having been set.
A revised patch is attached. Otherwise, it's okay: I verified
the leak fix and ran regression tests without exception.
The second patch checks out okay. It might be cleaner
and faster to alter the PyList_New for the correct number
of entries and then just use PyList_SET_ITEM. That saves
the double INCDEF followed by a DECREF and it shortens
the code a bit.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2003-01-17 05:44
Message:
Logged In: YES
user_id=6656
Looks fine to me.
I haven't tested it, but I assume it compiles and the tests
pass. I can't see how you could write a test for this.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=669553&group_id=5470