Issue 11335: Memory leak after key function failure in sort (original) (raw)

Created on 2011-02-26 17:02 by stutzbach, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
plug-leak.patch stutzbach,2011-02-26 17:12
Messages (11)
msg129574 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2011-02-26 17:02
In list.sort, if a key function throws an exception, the memory to store the keys is never freed. I introduced the bug in r86937. I'll upload a patch for review shortly.
msg129575 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2011-02-26 17:12
Below is a link to the code where leak occurs and the patch goes: http://svn.python.org/view/python/branches/py3k/Objects/listobject.c?view=markup&pathrev=88554#l1944
msg129579 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-02-26 17:33
LGTM
msg129925 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-03-02 23:46
Is there a way to test this?
msg129926 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-03-02 23:49
Valgrind perhaps? If the "keys" container was a list or tuple it would simply take a refleak run of the test suite.
msg129927 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2011-03-02 23:53
I'm not sure. What infrastructure do we have to leaked memory that was allocated with PyMem_MALLOC?
msg129928 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2011-03-02 23:53
I meant "to *detect* leaked memory", of course. :-)
msg129929 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2011-03-03 00:06
I played around with this a little. That code path doesn't appear to be exercised during the existing unit tests. I'll add a test so the leak at least shows up when the tests are run under valgrind.
msg134994 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2011-05-02 17:29
I checked in a fix to 3.3 just before the transition to hg. I confess that I've been procrastinating on getting hg set up properly, which is why I haven't gotten to checking this in to 3.2. Georg, if I get this in by Wednesday, will that be soon enough for your schedule for 3.2.1? (it sounds like it will be)
msg135000 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-05-02 19:12
Sure, Wednesday will be fine.
msg135155 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-04 20:06
New changeset 52fb7dc721ed by Daniel Stutzbach in branch '3.2': #11335: Fix memory leak after key function failure in sort http://hg.python.org/cpython/rev/52fb7dc721ed New changeset 18e43c6acfff by Daniel Stutzbach in branch 'default': #11335: Merge from 3.2: Fix memory leak after key function failure in sort http://hg.python.org/cpython/rev/18e43c6acfff
History
Date User Action Args
2022-04-11 14:57:13 admin set github: 55544
2011-05-04 20:08:26 stutzbach set status: open -> closedresolution: fixedstage: patch review -> resolved
2011-05-04 20:06:42 python-dev set nosy: + python-devmessages: +
2011-05-02 19:12:51 georg.brandl set messages: +
2011-05-02 17:29:54 stutzbach set priority: normal -> release blockernosy: + georg.brandlmessages: +
2011-03-03 00:06:11 stutzbach set nosy:rhettinger, pitrou, benjamin.peterson, stutzbachmessages: +
2011-03-02 23:53:52 stutzbach set nosy:rhettinger, pitrou, benjamin.peterson, stutzbachmessages: +
2011-03-02 23:53:13 stutzbach set nosy:rhettinger, pitrou, benjamin.peterson, stutzbachmessages: +
2011-03-02 23:49:01 pitrou set nosy:rhettinger, pitrou, benjamin.peterson, stutzbachmessages: +
2011-03-02 23:46:47 rhettinger set nosy:rhettinger, pitrou, benjamin.peterson, stutzbachmessages: +
2011-02-26 17:33:53 benjamin.peterson set nosy: + benjamin.petersonmessages: +
2011-02-26 17:12:55 stutzbach set files: + plug-leak.patchmessages: + keywords: + patch, needs review, 3.2regressionnosy:rhettinger, pitrou, stutzbach
2011-02-26 17:02:24 stutzbach create