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: 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:35adminsetgithub: 72168
2016-09-13 05:10:19python-devsetmessages: + msg276176
2016-09-13 04:40:28berker.peksagsetstatus: open -> closed

type: behavior
components: + Interpreter Core
versions: + Python 3.5, Python 3.7
nosy: + berker.peksag

messages: + msg276167
resolution: fixed
stage: resolved
2016-09-13 04:39:22python-devsetnosy: + python-dev
messages: + msg276166
2016-09-13 03:06:57David Dudson (BigDaveNz)setfiles: + 0001-Issue-27981-Prevent-a-leak-of-PyObject_CallObject-s-.patch

nosy: + David Dudson (BigDaveNz)
messages: + msg276153

keywords: + patch
2016-09-06 21:30:07serhiy.storchakasetmessages: + msg274635
2016-09-06 21:21:13vstinnersetmessages: + msg274633
2016-09-06 20:49:06serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg274623
2016-09-06 20:44:33vstinnercreate