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

Fixed various refcount issues in ElementTree iteration #70090

Closed
serhiy-storchaka opened this issue Dec 18, 2015 · 5 comments
Closed

Fixed various refcount issues in ElementTree iteration #70090

serhiy-storchaka opened this issue Dec 18, 2015 · 5 comments
Assignees
Labels
extension-modules C modules in the Modules dir topic-XML type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@serhiy-storchaka
Copy link
Member

BPO 25902
Nosy @vadmium, @serhiy-storchaka
Files
  • etree_iter_refcount.patch
  • etree_iter_refcount_2.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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2015-12-21.10:40:14.398>
    created_at = <Date 2015-12-18.12:04:44.709>
    labels = ['extension-modules', 'expert-XML', 'type-crash']
    title = 'Fixed various refcount issues in ElementTree iteration'
    updated_at = <Date 2015-12-21.10:40:14.396>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-12-21.10:40:14.396>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-12-21.10:40:14.398>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules', 'XML']
    creation = <Date 2015-12-18.12:04:44.709>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['41352', '41373']
    hgrepos = []
    issue_num = 25902
    keywords = ['patch']
    message_count = 5.0
    messages = ['256673', '256767', '256782', '256786', '256794']
    nosy_count = 3.0
    nosy_names = ['python-dev', 'martin.panter', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue25902'
    versions = ['Python 3.5', 'Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    ElementTree iteration code holds borrowed references when call user code (comparison with the tag, concatenating text and tail lazy lists, testing text and tail for empty). User code can make borrowed references invalid and this can lead to a crash. One example is provided by Martin in msg256495. Other possible cases can be more hard to reproduce.

    Proposed patch makes iterating code to own references that it operates.

    @serhiy-storchaka serhiy-storchaka added extension-modules C modules in the Modules dir topic-XML type-crash A hard crash of the interpreter, possibly with a core dump labels Dec 18, 2015
    @serhiy-storchaka serhiy-storchaka self-assigned this Dec 20, 2015
    @serhiy-storchaka
    Copy link
    Member Author

    Added tests.

    @vadmium
    Copy link
    Member

    vadmium commented Dec 21, 2015

    Left some comments about possibly unnecessary ref counting. Other than that it seems okay.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 21, 2015

    New changeset 00b6a13cfd70 by Serhiy Storchaka in branch '3.5':
    Issue bpo-25902: Fixed various refcount issues in ElementTree iteration.
    https://hg.python.org/cpython/rev/00b6a13cfd70

    New changeset e09cb2af3092 by Serhiy Storchaka in branch 'default':
    Issue bpo-25902: Fixed various refcount issues in ElementTree iteration.
    https://hg.python.org/cpython/rev/e09cb2af3092

    @serhiy-storchaka
    Copy link
    Member Author

    Thank you Martin.

    Actually this patch is for 3.5 only. In 3.6 the code will be rewrote (bpo-25873).

    @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
    extension-modules C modules in the Modules dir topic-XML type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants