Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference leak with custom tp_dealloc in PyType_FromSpec #60894

Closed
bfroehle mannequin opened this issue Dec 15, 2012 · 6 comments
Closed

Reference leak with custom tp_dealloc in PyType_FromSpec #60894

bfroehle mannequin opened this issue Dec 15, 2012 · 6 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@bfroehle
Copy link
Mannequin

bfroehle mannequin commented Dec 15, 2012

BPO 16690
Nosy @loewis, @ncoghlan, @pitrou, @encukou
Files
  • heaptype_refcnt_testcases.py
  • 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 = None
    closed_at = <Date 2019-09-12.14:43:43.606>
    created_at = <Date 2012-12-15.01:39:25.523>
    labels = ['interpreter-core', 'performance']
    title = 'Reference leak with custom tp_dealloc in PyType_FromSpec'
    updated_at = <Date 2019-09-12.14:43:43.605>
    user = 'https://bugs.python.org/bfroehle'

    bugs.python.org fields:

    activity = <Date 2019-09-12.14:43:43.605>
    actor = 'petr.viktorin'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-09-12.14:43:43.606>
    closer = 'petr.viktorin'
    components = ['Interpreter Core']
    creation = <Date 2012-12-15.01:39:25.523>
    creator = 'bfroehle'
    dependencies = []
    files = ['28372']
    hgrepos = []
    issue_num = 16690
    keywords = []
    message_count = 6.0
    messages = ['177527', '177528', '177794', '244420', '244814', '352187']
    nosy_count = 7.0
    nosy_names = ['loewis', 'ncoghlan', 'pitrou', 'petr.viktorin', 'python-dev', 'Robin.Schreiber', 'bfroehle']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue16690'
    versions = ['Python 3.2', 'Python 3.3', 'Python 3.4']

    @bfroehle
    Copy link
    Mannequin Author

    bfroehle mannequin commented 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:

    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

    @bfroehle bfroehle mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage labels Dec 15, 2012
    @bfroehle
    Copy link
    Mannequin Author

    bfroehle mannequin commented Dec 15, 2012

    I see this issue came up in the course of bpo-15653 as well.

    @bfroehle
    Copy link
    Mannequin Author

    bfroehle mannequin commented Dec 20, 2012

    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.

    @ncoghlan
    Copy link
    Contributor

    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
    Copy link
    Mannequin

    python-dev mannequin commented 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
    Copy link
    Member

    encukou commented Sep 12, 2019

    This is fixed in Python 3.5+.

    @encukou encukou closed this as completed Sep 12, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants