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: various refleaks when calling the __init__() method of an object more than once
Type: resource usage Stage: resolved
Components: Extension Modules Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Oren Milman, cheryl.sabella, methane, miss-islington, rhettinger, vstinner
Priority: normal Keywords: patch

Created on 2017-10-14 09:16 by Oren Milman, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3995 merged Oren Milman, 2017-10-14 09:43
PR 5657 merged miss-islington, 2018-02-13 10:29
PR 5659 merged methane, 2018-02-13 11:41
PR 5660 merged methane, 2018-02-13 14:04
PR 5661 merged miss-islington, 2018-02-13 14:42
PR 5662 merged miss-islington, 2018-02-13 14:43
Messages (9)
msg304389 - (view) Author: Oren Milman (Oren Milman) * Date: 2017-10-14 09:16
Various __init__() methods don't decref (if needed) before assigning to fields
of the object's struct (i.e. assigning to `self->some_field`):
- _asyncio_Task___init___impl() (in Modules/_asynciomodule.c)
- _lzma_LZMADecompressor___init___impl() (in Modules/_lzmamodule.c)
- _bz2_BZ2Decompressor___init___impl() (in Modules/_bz2module.c)
- EVP_tp_init() (in Modules/_hashopenssl.c)
- property_init_impl() (in Objects/descrobject.c)
- cm_init() (in Objects/funcobject.c)
- sm_init() (in Objects/funcobject.c)

For example, _asyncio_Task___init___impl() does `self->task_coro = coro;`
instead of `Py_XSETREF(self->task_coro, coro);`.
Thus, the following code would result in at least one refleak:
import _asyncio
task = _asyncio.Task('foo')
task.__init__('foo')


I would open a PR to fix this soon.
msg310387 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2018-01-21 23:12
Raymond,

You approved this PR pending some test cases.  Would you have the chance to take another look?

Thanks!


Oren, it looks like you'll need to rebase before this could be merged.
msg312113 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-02-13 10:28
New changeset d019bc8319ea35e93bf4baa38098ff1b57cd3ee5 by INADA Naoki (Oren Milman) in branch 'master':
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
https://github.com/python/cpython/commit/d019bc8319ea35e93bf4baa38098ff1b57cd3ee5
msg312116 - (view) Author: miss-islington (miss-islington) Date: 2018-02-13 11:32
New changeset ef20abed7f2ae0ba54b1d287f5fe601be80c1128 by Miss Islington (bot) in branch '3.7':
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
https://github.com/python/cpython/commit/ef20abed7f2ae0ba54b1d287f5fe601be80c1128
msg312118 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-02-13 13:15
New changeset 47316342417146f62653bc3c3dd505bfacc5e956 by INADA Naoki in branch '3.6':
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
https://github.com/python/cpython/commit/47316342417146f62653bc3c3dd505bfacc5e956
msg312124 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-02-13 14:41
New changeset f0bc645dfede8118c84844bad319cd952c4d1905 by INADA Naoki in branch 'master':
bpo-31787: Skip refleak check when _hashlib is not available (GH-5660)
https://github.com/python/cpython/commit/f0bc645dfede8118c84844bad319cd952c4d1905
msg312126 - (view) Author: miss-islington (miss-islington) Date: 2018-02-13 15:07
New changeset e81a6c86c89da02a0da719926198ab72edab2e05 by Miss Islington (bot) in branch '3.7':
bpo-31787: Skip refleak check when _hashlib is not available (GH-5660)
https://github.com/python/cpython/commit/e81a6c86c89da02a0da719926198ab72edab2e05
msg312128 - (view) Author: miss-islington (miss-islington) Date: 2018-02-13 15:33
New changeset 5d0d0eaf3ccee4349a5bed6e7741d09d56f2ab50 by Miss Islington (bot) in branch '3.6':
bpo-31787: Skip refleak check when _hashlib is not available (GH-5660)
https://github.com/python/cpython/commit/5d0d0eaf3ccee4349a5bed6e7741d09d56f2ab50
msg320088 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-20 16:00
It seems like the lzma fix is incomplete: bpo-33916, "test_lzma: test_refleaks_in_decompressor___init__() leaks 100 handles on Windows".
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 75968
2018-06-20 16:00:04vstinnersetnosy: + vstinner
messages: + msg320088
2018-02-13 15:33:52miss-islingtonsetmessages: + msg312128
2018-02-13 15:07:40miss-islingtonsetmessages: + msg312126
2018-02-13 14:43:29miss-islingtonsetpull_requests: + pull_request5465
2018-02-13 14:42:34miss-islingtonsetpull_requests: + pull_request5464
2018-02-13 14:41:23methanesetmessages: + msg312124
2018-02-13 14:04:58methanesetpull_requests: + pull_request5463
2018-02-13 13:15:49methanesetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.6, Python 3.8
2018-02-13 13:15:28methanesetmessages: + msg312118
2018-02-13 11:41:31methanesetpull_requests: + pull_request5462
2018-02-13 11:32:21miss-islingtonsetnosy: + miss-islington
messages: + msg312116
2018-02-13 10:29:47miss-islingtonsetpull_requests: + pull_request5459
2018-02-13 10:28:40methanesetnosy: + methane
messages: + msg312113
2018-01-21 23:12:25cheryl.sabellasetnosy: + rhettinger, cheryl.sabella
messages: + msg310387
2017-10-14 09:43:06Oren Milmansetkeywords: + patch
stage: patch review
pull_requests: + pull_request3971
2017-10-14 09:16:28Oren Milmancreate