Issue 27981: Reference leak in fp_setreadl() of Parser/tokenizer.c (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/72168

classification

Title: Reference leak in fp_setreadl() of Parser/tokenizer.c
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7, Python 3.6, Python 3.5

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: David Dudson (BigDaveNz), berker.peksag, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2016-09-06 20:44 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
0001-Issue-27981-Prevent-a-leak-of-PyObject_CallObject-s-.patch David Dudson (BigDaveNz),2016-09-13 03:06
Messages (8)
msg274622 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-09-06 20:44
Does the following function call leaks a reference? if (PyObject_CallObject(readline, NULL) == NULL) { readline = NULL; goto cleanup; }
msg274623 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-09-06 20:49
No, readline is borrowed reference.
msg274633 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-09-06 21:21
Serhiy Storchaka added the comment: > No, readline is borrowed reference. My question is one the function call result. What if it is not NULL: I don't see any DECREF.
msg274635 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-09-06 21:30
Ah, you are right, there is a leak.
msg276153 - (view) Author: David Dudson (BigDaveNz) (David Dudson (BigDaveNz)) * Date: 2016-09-13 03:06
Please find a fix attached. This applies cleanly to 3.5/3.6/3.7 but not 2.7 Ran tests on 3.7 (master branch HEAD) only.
msg276166 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-13 04:39
New changeset aa88456f1749 by Berker Peksag in branch '3.5': Issue #27981: Fix refleak in fp_setreadl() https://hg.python.org/cpython/rev/aa88456f1749 New changeset 095c77323a6e by Berker Peksag in branch '3.6': Issue #27981: Merge from 3.5 https://hg.python.org/cpython/rev/095c77323a6e New changeset e4b16748aca2 by Berker Peksag in branch 'default': Issue #27981: Merge from 3.6 https://hg.python.org/cpython/rev/e4b16748aca2
msg276167 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-09-13 04:40
Thanks for the patch, David!
msg276176 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-13 05:10
New changeset 2be31da53dcc by Benjamin Peterson in branch '3.5': restructure fp_setreadl so as to avoid refleaks (closes #27981) https://hg.python.org/cpython/rev/2be31da53dcc New changeset 4ac3de437100 by Benjamin Peterson in branch '3.6': merge 3.5 (#27981) https://hg.python.org/cpython/rev/4ac3de437100 New changeset aa63b94946bf by Benjamin Peterson in branch 'default': merge 3.6 (#27981) https://hg.python.org/cpython/rev/aa63b94946bf
History
Date User Action Args
2022-04-11 14:58:35 admin set github: 72168
2016-09-13 05:10:19 python-dev set messages: +
2016-09-13 04:40:28 berker.peksag set status: open -> closedtype: behaviorcomponents: + Interpreter Coreversions: + Python 3.5, Python 3.7nosy: + berker.peksagmessages: + resolution: fixedstage: resolved
2016-09-13 04:39:22 python-dev set nosy: + python-devmessages: +
2016-09-13 03:06:57 David Dudson (BigDaveNz) set files: + 0001-Issue-27981-Prevent-a-leak-of-PyObject_CallObject-s-.patchnosy: + David Dudson (BigDaveNz)messages: + keywords: + patch
2016-09-06 21:30:07 serhiy.storchaka set messages: +
2016-09-06 21:21:13 vstinner set messages: +
2016-09-06 20:49:06 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2016-09-06 20:44:33 vstinner create