This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: fix memory (ref) leaks
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: mwh, nnorwitz, rhettinger
Priority: normal Keywords: patch

Created on 2003-01-17 04:02 by nnorwitz, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
leaks.diff nnorwitz, 2003-01-17 04:03 leaks patch 1
int.diff rhettinger, 2003-01-19 00:04 Revised patch to intobject.c
Messages (5)
msg42437 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-01-17 04:02
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__
msg42438 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2003-01-17 10:44
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.
msg42439 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-01-19 00:04
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.
msg42440 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-01-19 03:00
Logged In: YES 
user_id=80475

When the patches are fixed-up, they should also be 
backported.
msg42441 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-01-19 15:52
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
History
Date User Action Args
2022-04-10 16:06:08adminsetgithub: 37785
2003-01-17 04:02:36nnorwitzcreate