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

Keep a refence to mro in _PyType_Lookup() and super_getattro() #58407

Closed
vstinner opened this issue Mar 5, 2012 · 3 comments
Closed

Keep a refence to mro in _PyType_Lookup() and super_getattro() #58407

vstinner opened this issue Mar 5, 2012 · 3 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@vstinner
Copy link
Member

vstinner commented Mar 5, 2012

BPO 14199
Nosy @vstinner, @markshannon
Files
  • type_lookup_mro.patch
  • 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 2012-03-08.23:39:09.177>
    created_at = <Date 2012-03-05.12:33:27.714>
    labels = ['interpreter-core', 'type-crash']
    title = 'Keep a refence to mro in _PyType_Lookup() and super_getattro()'
    updated_at = <Date 2012-03-08.23:39:09.170>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2012-03-08.23:39:09.170>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-03-08.23:39:09.177>
    closer = 'python-dev'
    components = ['Interpreter Core']
    creation = <Date 2012-03-05.12:33:27.714>
    creator = 'vstinner'
    dependencies = []
    files = ['24736']
    hgrepos = []
    issue_num = 14199
    keywords = ['patch']
    message_count = 3.0
    messages = ['154943', '154990', '155186']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'Mark.Shannon', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue14199'
    versions = ['Python 3.3']

    @vstinner
    Copy link
    Member Author

    vstinner commented Mar 5, 2012

    Lib/test/crashers/losing_mro_ref.py does crash Python: _PyType_Lookup() borrows a reference to the type MRO, but the type MRO is replaced during the lookup. Python crashs because it reads an item from a tuple that was destroyed (in the specific test, it reads an item from a newly created tuple which is not the type MRO).

    Attached patch keeps a strong reference to the type MRO during the lookup to workaround this crasher. It fixes Lib/test/crashers/losing_mro_ref.py.

    If changing temporary has an impact on performances, a guard can be used to check that the type MRO has not been changed during the lookup.

    @vstinner vstinner added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels Mar 5, 2012
    @markshannon
    Copy link
    Member

    Looks good to me.

    The INCREF/DECREFs are outside of the loops so will have negligible performance impact.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 8, 2012

    New changeset 21e245ed3747 by Victor Stinner in branch 'default':
    Close bpo-14199: _PyType_Lookup() and super_getattro() keep a strong reference to
    http://hg.python.org/cpython/rev/21e245ed3747

    @python-dev python-dev mannequin closed this as completed Mar 8, 2012
    @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) type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants