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: structseq.c: refleak
Type: resource usage Stage: resolved
Components: Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Suman.Saha, ezio.melotti, meador.inge, pitrou, python-dev, torsten
Priority: normal Keywords:

Created on 2011-09-20 14:57 by Suman.Saha, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python_patch8 Suman.Saha, 2011-09-20 14:57 Patch review
Messages (6)
msg144337 - (view) Author: Suman Saha (Suman.Saha) Date: 2011-09-20 14:57
Something that is allocated using PySequence_Fast is not freed on one error path.
msg144339 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-09-20 15:09
Hi, thanks for the report(s) and the patch(es)!
I think it would be better to have a test that shows the refleak for each of the patches that you submitted.
Just out of curiosity, how did you find these?
msg144398 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2011-09-22 02:52
In general I agree that a test case is needed, but in this particular
case its looks to be non-trivial to come up with one.  The only way
the reference leak is triggered is when memory is exhausted during an
attempt to new up a 'PyStructSequence' object.
msg151656 - (view) Author: Torsten Landschoff (torsten) * Date: 2012-01-19 21:52
+1 for the patch.
All the error paths above the change do

  Py_DECREF(arg);
  return NULL;

arg is initialized with PySequence_Fast, which returns a new reference.
Hard to create a test case for this...
msg153387 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-15 02:00
New changeset 6454e5de7c34 by Antoine Pitrou in branch '3.2':
Issue #13020: Fix a reference leak when allocating a structsequence object fails.
http://hg.python.org/cpython/rev/6454e5de7c34

New changeset 5e0085d67f65 by Antoine Pitrou in branch 'default':
Issue #13020: Fix a reference leak when allocating a structsequence object fails.
http://hg.python.org/cpython/rev/5e0085d67f65

New changeset 08a85fc85bf2 by Antoine Pitrou in branch '2.7':
Issue #13020: Fix a reference leak when allocating a structsequence object fails.
http://hg.python.org/cpython/rev/08a85fc85bf2
msg153388 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-02-15 02:01
I've now committed the patch. Thanks for contributing!
History
Date User Action Args
2022-04-11 14:57:21adminsetgithub: 57229
2012-02-15 02:01:29pitrousetstatus: open -> closed

versions: + Python 2.7, Python 3.2, Python 3.3
nosy: + pitrou

messages: + msg153388
resolution: fixed
stage: test needed -> resolved
2012-02-15 02:00:55python-devsetnosy: + python-dev
messages: + msg153387
2012-01-19 21:52:33torstensetnosy: + torsten
messages: + msg151656
2011-09-22 02:52:35meador.ingesetnosy: + meador.inge
messages: + msg144398
2011-09-21 19:23:21skrahsettitle: Resource is not released before returning from the functiion -> structseq.c: refleak
2011-09-20 15:09:54ezio.melottisetnosy: + ezio.melotti

messages: + msg144339
stage: test needed
2011-09-20 14:57:35Suman.Sahacreate