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

Stack overflow error with asyncio.all_tasks and wait_for #86349

Closed
Gobot1234 mannequin opened this issue Oct 28, 2020 · 7 comments
Closed

Stack overflow error with asyncio.all_tasks and wait_for #86349

Gobot1234 mannequin opened this issue Oct 28, 2020 · 7 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes topic-asyncio type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@Gobot1234
Copy link
Mannequin

Gobot1234 mannequin commented Oct 28, 2020

BPO 42183
Nosy @asvetlov, @1st1, @miss-islington, @Gobot1234
PRs
  • bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() #23020
  • [3.9] bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() (GH-23020) #23221
  • [3.8] bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() (GH-23020) #23222
  • [3.7] bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() (GH-23020) #23223
  • 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 2020-11-10.14:31:52.655>
    created_at = <Date 2020-10-28.16:59:24.314>
    labels = ['3.10', '3.8', '3.9', 'type-crash', 'expert-asyncio']
    title = 'Stack overflow error with asyncio.all_tasks and wait_for'
    updated_at = <Date 2020-11-10.14:31:52.655>
    user = 'https://github.com/Gobot1234'

    bugs.python.org fields:

    activity = <Date 2020-11-10.14:31:52.655>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-11-10.14:31:52.655>
    closer = 'asvetlov'
    components = ['asyncio']
    creation = <Date 2020-10-28.16:59:24.314>
    creator = 'Gobot1234'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42183
    keywords = ['patch']
    message_count = 7.0
    messages = ['379837', '379857', '379858', '379860', '380667', '380672', '380673']
    nosy_count = 4.0
    nosy_names = ['asvetlov', 'yselivanov', 'miss-islington', 'Gobot1234']
    pr_nums = ['23020', '23221', '23222', '23223']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue42183'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @Gobot1234
    Copy link
    Mannequin Author

    Gobot1234 mannequin commented Oct 28, 2020

    Using asyncio.wait_for and asyncio.all_tasks in combination causes a stack overflow error.

    Code to reproduce issue:

    import asyncio
    
    async def func():
        return asyncio.all_tasks()
    
    async def main():
        print(await asyncio.wait_for(func(), timeout=10))
    
    asyncio.run(main())
    

    I'm not too sure how far back this goes but I've managed to reproduce it on sys.version_info(major=3, minor=8, micro=0, releaselevel='final', serial=0) and sys.version_info(major=3, minor=9, micro=0, releaselevel='final', serial=0).

    @Gobot1234 Gobot1234 mannequin added 3.8 only security fixes 3.9 only security fixes topic-asyncio labels Oct 28, 2020
    @asvetlov
    Copy link
    Contributor

    I cannot reproduce on 3.9 but 3.8.6 crashes on repr:

    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/asyncio/base_futures.py", line 31 in format_cb
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/asyncio/base_futures.py", line 34 in _format_callbacks
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/asyncio/base_futures.py", line 57 in _future_repr_info
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/asyncio/base_tasks.py", line 9 in _task_repr_info
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/reprlib.py", line 139 in repr_instance
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/reprlib.py", line 62 in repr1
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/reprlib.py", line 71 in <listcomp>
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/reprlib.py", line 71 in _repr_iterable
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/reprlib.py", line 93 in repr_set
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/reprlib.py", line 60 in repr1
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/reprlib.py", line 52 in repr
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/asyncio/base_futures.py", line 54 in _future_repr_info
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/asyncio/base_tasks.py", line 9 in _task_repr_info
    File "/home/andrew/.pyenv/versions/3.8.6/lib/python3.8/reprlib.py", line 139 in repr_instance
    ... the stack tail recursively repeats

    @asvetlov
    Copy link
    Contributor

    Update: the bug is present in all supported Python versions bug sometimes may be hidden by race conditions.

    @asvetlov asvetlov added 3.7 (EOL) end of life 3.10 only security fixes type-crash A hard crash of the interpreter, possibly with a core dump labels Oct 29, 2020
    @asvetlov
    Copy link
    Contributor

    The fix is ready

    @asvetlov
    Copy link
    Contributor

    New changeset 42d873c by Andrew Svetlov in branch 'master':
    bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() (GH-23020)
    42d873c

    @miss-islington
    Copy link
    Contributor

    New changeset 90115a2 by Miss Islington (bot) in branch '3.9':
    bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() (GH-23020)
    90115a2

    @miss-islington
    Copy link
    Contributor

    New changeset 109c173 by Miss Islington (bot) in branch '3.8':
    bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() (GH-23020)
    109c173

    @asvetlov asvetlov removed the 3.7 (EOL) end of life label Nov 10, 2020
    @asvetlov asvetlov removed the 3.7 (EOL) end of life label Nov 10, 2020
    @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
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes topic-asyncio type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants