[New-bugs-announce] [issue31787] various refleaks when calling the __init__() method of an object more than once

Oren Milman report at bugs.python.org
Sat Oct 14 05:16:28 EDT 2017


New submission from Oren Milman <orenmn at gmail.com>:

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.

----------
components: Extension Modules
messages: 304389
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: various refleaks when calling the __init__() method of an object more than once
type: resource usage
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31787>
_______________________________________


More information about the New-bugs-announce mailing list