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: memory leak in listxattr()
Type: resource usage Stage: resolved
Components: Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, christian.heimes, pitrou, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-05-13 09:48 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
listxattr_leak.patch pitrou, 2013-05-13 09:48 review
Messages (8)
msg189114 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-05-13 09:48
os.listxattr() leaks its internal buffer when the first call to C listxattr() fails with ERANGE. This wasn't caught by the refleak bot, probably because xattrs are not enabled on it.
msg189127 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-13 13:19
LGTM
msg189134 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-05-13 14:05
LGTM
msg189156 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-05-13 17:48
New changeset 2187cf880e5b by Antoine Pitrou in branch '3.3':
Issue #17968: Fix memory leak in os.listxattr().
http://hg.python.org/cpython/rev/2187cf880e5b

New changeset 1fa1a021ed23 by Antoine Pitrou in branch 'default':
Issue #17968: Fix memory leak in os.listxattr().
http://hg.python.org/cpython/rev/1fa1a021ed23
msg189157 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-05-13 17:49
Should be fixed now.
msg189189 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-05-14 00:53
Coverity complains that your patch has introduced a double free bug. Can you have a look, please?

** CID 1021198: Double free (USE_AFTER_FREE)
/Modules/posixmodule.c: 10161
http://scan5.coverity.com:8080//sourcebrowser.htm?projectId=10226#mergedDefectId=1021198


________________________________________________________________________
CID 1021198: Double free (USE_AFTER_FREE)

/Modules/posixmodule.c: 10123 ( freed_arg)
   10120    
   10121            if (length < 0) {
   10122                if (errno == ERANGE) {
>>> "free(void *)" frees "buffer".
   10123                    PyMem_FREE(buffer);
   10124                    continue;
   10125                }
   10126                path_error(&path);
   10127                break;
  

/Modules/posixmodule.c: 10161 ( double_free)
   10158    exit:
   10159        path_cleanup(&path);
   10160        if (buffer)
>>> CID 1021198: Double free (USE_AFTER_FREE)
>>> Calling "free(void *)" frees pointer "buffer" which has already been freed.
   10161            PyMem_FREE(buffer);
   10162        return result;
   10163    }
   10164    
   10165    #endif /* USE_XATTRS */
msg189190 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-05-14 00:56
New changeset 7aa157971810 by Benjamin Peterson in branch '3.3':
prevent double free in cleanup code (#17968)
http://hg.python.org/cpython/rev/7aa157971810

New changeset 617cb2f978b0 by Benjamin Peterson in branch 'default':
merge 3.3 (#17968)
http://hg.python.org/cpython/rev/617cb2f978b0
msg189191 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-05-14 00:57
Technically a false alarm but it is a danger in the future.
History
Date User Action Args
2022-04-11 14:57:45adminsetgithub: 62168
2013-05-14 00:57:22benjamin.petersonsetstatus: open -> closed

messages: + msg189191
2013-05-14 00:56:47python-devsetmessages: + msg189190
2013-05-14 00:53:34christian.heimessetstatus: closed -> open
nosy: + christian.heimes
messages: + msg189189

2013-05-13 17:49:21pitrousetstatus: open -> closed
resolution: fixed
messages: + msg189157

stage: patch review -> resolved
2013-05-13 17:48:57python-devsetnosy: + python-dev
messages: + msg189156
2013-05-13 14:05:11benjamin.petersonsetmessages: + msg189134
2013-05-13 13:19:44serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg189127
2013-05-13 09:48:46pitroucreate