python / cpython

The Python programming language
https://www.python.org/
Other
61.16k stars 29.52k forks source link

Test for closing delegating generator with cleared frame (Issue17669) #62765

Closed 0f33552e-3426-4ce7-83ad-4a88a6ffc812 closed 10 years ago

0f33552e-3426-4ce7-83ad-4a88a6ffc812 commented 10 years ago
BPO 18565
Nosy @benjaminp, @phmc
Files
  • gen_close_with_cleared_frame.diff
  • gen_close_with_cleared_frame.diff
  • 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: ```python assignee = None closed_at = created_at = labels = ['interpreter-core', 'type-feature'] title = 'Test for closing delegating generator with cleared frame (Issue17669)' updated_at = user = 'https://github.com/phmc' ``` bugs.python.org fields: ```python activity = actor = 'python-dev' assignee = 'none' closed = True closed_date = closer = 'python-dev' components = ['Interpreter Core'] creation = creator = 'pconnell' dependencies = [] files = ['31048', '31055'] hgrepos = [] issue_num = 18565 keywords = ['patch'] message_count = 4.0 messages = ['193765', '193775', '193794', '193798'] nosy_count = 4.0 nosy_names = ['benjamin.peterson', 'python-dev', 'pconnell', 'isoschiz'] pr_nums = [] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue18565' versions = ['Python 3.4'] ```

    0f33552e-3426-4ce7-83ad-4a88a6ffc812 commented 10 years ago

    This is a testcase for bpo-17669 - it passes against the latest default (and hits the same segfault under 3.3.0).

    I came up with this while tracking down a thorny generator finalisation crash that turned out to be a variant on 17669.

    The root cause was gen_close being called on a generator that's delegating to another, and whose frame has already had frame_clear called (so f_stacktop is NULL).

    It's reproduced by creating a reference cycle that's broken by clearing the delegating generator's frame.

    benjaminp commented 10 years ago

    Thanks! It looks good except I think you could use the support.disable_gc() context manager.

    0f33552e-3426-4ce7-83ad-4a88a6ffc812 commented 10 years ago

    Good suggestion, updated patch attached.

    1762cc99-3127-4a62-9baf-30c3d0f51ef7 commented 10 years ago

    New changeset 516303f32bad by Benjamin Peterson in branch '3.3': add a test for issue bpo-17669 (closes bpo-18565) http://hg.python.org/cpython/rev/516303f32bad

    New changeset f90e7540dcba by Benjamin Peterson in branch 'default': merge 3.3 (bpo-18565) http://hg.python.org/cpython/rev/f90e7540dcba