You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reference leak with custom tp_dealloc in PyType_FromSpec #60894
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2019-09-12.14:43:43.606>created_at=<Date2012-12-15.01:39:25.523>labels= ['interpreter-core', 'performance']
title='Reference leak with custom tp_dealloc in PyType_FromSpec'updated_at=<Date2019-09-12.14:43:43.605>user='https://bugs.python.org/bfroehle'
There is a reference leak when using PyType_FromSpec with custom tp_dealloc. This was first noted in issue bpo-15142, where a fix was given which only applies to types which do not override tp_dealloc.
For example, the xxlimited.Xxo type suffers from this:
Python 3.3.0 (default, Oct 26 2012, 11:06:17)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xxlimited
>>> import sys
>>> Xxo =type(xxlimited.new())
>>> e = Xxo()
>>> sys.getrefcount(Xxo)
7
>>> e = Xxo()
>>> sys.getrefcount(Xxo)
8
>>> e = Xxo()
>>> sys.getrefcount(Xxo)
9
I see this issue came up in the course of bpo-15653 as well.
bfroehle commented on Dec 20, 2012
bfroehlemannequin
MannequinAuthor
More actions
The attached file heaptype_refcnt_testcases.py runs through several test cases (ssl.SSLError, a subclass of ssl.SSLError, and xxlimited.Xxo) seeing if references are leaked in each instance.
Unfortunately xxlimited.Xxo isn't set to be a base type and I don't know of any other types in the default install which use PyType_FromSpec with a custom tp_dealloc.
Activity
bfroehle commentedon Dec 15, 2012
There is a reference leak when using PyType_FromSpec with custom tp_dealloc. This was first noted in issue bpo-15142, where a fix was given which only applies to types which do not override tp_dealloc.
For example, the xxlimited.Xxo type suffers from this:
bfroehle commentedon Dec 15, 2012
I see this issue came up in the course of bpo-15653 as well.
bfroehle commentedon Dec 20, 2012
The attached file
heaptype_refcnt_testcases.pyruns through several test cases (ssl.SSLError, a subclass of ssl.SSLError, and xxlimited.Xxo) seeing if references are leaked in each instance.Unfortunately
xxlimited.Xxoisn't set to be a base type and I don't know of any other types in the default install which use PyType_FromSpec with a custom tp_dealloc.ncoghlan commentedon May 29, 2015
The new test cases for PEP-489 (multi-phase extension module import) appear to be encountering this leak.
See bpo-24268 for context.
python-dev commentedon Jun 4, 2015
New changeset 265eeb60443a by Nick Coghlan in branch '3.5':
Issue bpo-24373: Eliminate PEP-489 test refleaks
https://hg.python.org/cpython/rev/265eeb60443a
encukou commentedon Sep 12, 2019
This is fixed in Python 3.5+.