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.

Title: Fix reference leak in dict_setdefault() in case of resize failure
Type: resource usage Stage: resolved
Components: Interpreter Core Versions: Python 3.3, Python 3.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, python-dev, scoder, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-03-01 14:03 by scoder, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
dict_setdefault_refleak.patch scoder, 2013-03-01 14:03 fix for the reference leaks review
Messages (3)
msg183261 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2013-03-01 14:03
While writing the patch for issue 17327, I noticed that there is a double reference leak in dict_setdefault() under the rare condition that resizing fails. I'm not 100% sure that it's ok to move the increfs behind the resizing, but considering that the resizing code actually looks safe and shouldn't kill references that are currently in the dict, I don't think it can be a problem. And the caller should always own a reference to these two anyway. Alternatively, decrefing them if the failure occurs would be a less intrusive change.
msg183424 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-03-04 08:22
LGTM. This is 3.3+ only issue as far as I understand.
msg183460 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-03-04 14:48
New changeset 1a589001d752 by Benjamin Peterson in branch '3.3':
fix possible setdefault refleak (closes #17328)

New changeset fac46cf6af3f by Benjamin Peterson in branch 'default':
merge 3.3 (#17328)
Date User Action Args
2022-04-11 14:57:42adminsetgithub: 61530
2013-03-04 14:48:38python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg183460

resolution: fixed
stage: patch review -> resolved
2013-03-04 08:22:36serhiy.storchakasetnosy: + benjamin.peterson

messages: + msg183424
versions: - Python 2.6, Python 2.7, Python 3.2
2013-03-01 19:24:15ezio.melottisetnosy: + serhiy.storchaka

stage: patch review
2013-03-01 14:03:53scodercreate