This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Stack overflow error with asyncio.all_tasks and wait_for
Type: crash Stage: resolved
Components: asyncio Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Gobot1234, asvetlov, miss-islington, yselivanov
Priority: normal Keywords: patch

Created on 2020-10-28 16:59 by Gobot1234, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 23020 merged asvetlov, 2020-10-29 09:22
PR 23221 merged miss-islington, 2020-11-10 13:58
PR 23222 merged miss-islington, 2020-11-10 13:58
PR 23223 closed miss-islington, 2020-11-10 13:59
Messages (7)
msg379837 - (view) Author: Gobot1234 (Gobot1234) * Date: 2020-10-28 16:59
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).
msg379857 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-10-29 08:27
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
msg379858 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-10-29 09:13
Update: the bug is present in all supported Python versions bug sometimes may be hidden by race conditions.
msg379860 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-10-29 09:23
The fix is ready
msg380667 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-11-10 13:58
New changeset 42d873c63aa9d160c132be4a34599531574db12c by Andrew Svetlov in branch 'master':
bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() (GH-23020)
https://github.com/python/cpython/commit/42d873c63aa9d160c132be4a34599531574db12c
msg380672 - (view) Author: miss-islington (miss-islington) Date: 2020-11-10 14:20
New changeset 90115a2cf7033c990a54d1ecb90ebd850b5f13cf by Miss Islington (bot) in branch '3.9':
bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() (GH-23020)
https://github.com/python/cpython/commit/90115a2cf7033c990a54d1ecb90ebd850b5f13cf
msg380673 - (view) Author: miss-islington (miss-islington) Date: 2020-11-10 14:21
New changeset 109c17315af124b25853c248f4a9bf00f03036f6 by Miss Islington (bot) in branch '3.8':
bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() (GH-23020)
https://github.com/python/cpython/commit/109c17315af124b25853c248f4a9bf00f03036f6
History
Date User Action Args
2022-04-11 14:59:37adminsetgithub: 86349
2020-11-10 14:31:52asvetlovsetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: - Python 3.7
2020-11-10 14:21:56miss-islingtonsetmessages: + msg380673
2020-11-10 14:20:55miss-islingtonsetmessages: + msg380672
2020-11-10 13:59:02miss-islingtonsetpull_requests: + pull_request22121
2020-11-10 13:58:54miss-islingtonsetpull_requests: + pull_request22120
2020-11-10 13:58:47miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request22119
2020-11-10 13:58:35asvetlovsetmessages: + msg380667
2020-10-29 09:23:59asvetlovsetmessages: + msg379860
2020-10-29 09:22:09asvetlovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request21934
2020-10-29 09:14:03asvetlovsettype: crash
versions: + Python 3.7, Python 3.10
2020-10-29 09:13:13asvetlovsetmessages: + msg379858
2020-10-29 08:27:55asvetlovsetmessages: + msg379857
2020-10-28 16:59:24Gobot1234create