GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `python -m asyncio ps` fails if any task name is longer than 255 characters · Issue #157788 · python/cpython

python -m asyncio ps fails if any task name is longer than 255 characters #157788

Copy link
Copy link
Closed
Closed
python -m asyncio ps fails if any task name is longer than 255 characters#157788
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@deadlovelll
deadlovelll
opened on Sep 19, 2026
Issue body actions

Bug report

Bug description:

One task name longer than 255 characters makes python -m asyncio ps fail for the whole process. The length limit is treated as a validity check instead of a cap.

Repro:

  import asyncio
  import os
  from _remote_debugging import RemoteUnwinder

  async def main():
      asyncio.create_task(asyncio.sleep(10), name='x' * 256)
      await asyncio.sleep(0)
      print(RemoteUnwinder(os.getpid()).get_all_awaited_by())

  asyncio.run(main())

Actually:

  Traceback (most recent call last):
    File "/Users/timofeiivankov/cpython/repro.py", line 10, in <module>
      asyncio.run(main())
      ~~~~~~~~~~~^^^^^^^^
    File "/Users/timofeiivankov/cpython/Lib/asyncio/runners.py", line 205, in run
      return runner.run(main)
             ~~~~~~~~~~^^^^^^
    File "/Users/timofeiivankov/cpython/Lib/asyncio/runners.py", line 128, in run
      return self._loop.run_until_complete(task)
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
    File "/Users/timofeiivankov/cpython/Lib/asyncio/base_events.py", line 725, in run_until_complete
      return future.result()
             ~~~~~~~~~~~~~^^
    File "/Users/timofeiivankov/cpython/repro.py", line 8, in main
      print(RemoteUnwinder(os.getpid()).get_all_awaited_by())
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  RuntimeError: Invalid string length (256) at 0x101493800

Expected: the call returns and the long name comes back truncated:

[AwaitedInfo(thread_id=21170325, awaited_by=[
  TaskInfo(task_id=4312485712, task_name='Task-1', ...),
  TaskInfo(task_id=4312485232, task_name='xxx…' (truncated to 255), ...)])]

Proposed fix: Truncate to the limit instead of raising in object_reading.c

I have a fix ready for that

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

  • gh-157788: Fix python -m asyncio ps failing on long task names #157790
  • [3.14] gh-157788: Fix python -m asyncio ps failing on long task names #157843
  • [3.15] gh-157788: Fix python -m asyncio ps failing on long task names (GH-157790) #157826
  • gh-157788: Fix test_long_task_name_is_truncated by not hardcoding main task name #157911
  • [3.15] gh-157788: Fix test_long_task_name_is_truncated by not hardcoding main task name (GH-157911) #157941
  • [3.14] gh-157788: Fix test_long_task_name_is_truncated by not hardcoding main task name (GH-157911) #157942

Activity

  1. deadlovelll
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Sep 19, 2026
  2. aisk
    added
    topic-asyncio
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Sep 19, 2026
  3. github-project-automation
    added this to asyncioon Sep 19, 2026
  4. github-project-automation
    moved this to Todo in asyncioon Sep 19, 2026
  5. kumaraditya303
    closed this as completedon Sep 21, 2026
  6. github-project-automation
    moved this from Todo to Done in asyncioon Sep 21, 2026
  7. hugovk
    added a commit that references this issue on Sep 21, 2026

    [3.15] gh-157788: Fix python -m asyncio ps failing on long task names (…

    074a2cd
  8. kumaraditya303
    added a commit that references this issue on Sep 21, 2026

    [3.14] gh-157788: Fix python -m asyncio ps failing on long task names (…

    04b7fff
  9. encukou commented on Sep 21, 2026

    @encukou
    encukou
    on Sep 21, 2026
    Member
    More actions

    The new test fails on refleaks buildbots, see e.g. https://buildbot.python.org/#/builders/2263/builds/295

  10. encukou
    reopened this on Sep 21, 2026
  11. github-project-automation
    moved this from Done to In Progress in asyncioon Sep 21, 2026
  12. deadlovelll commented on Sep 21, 2026

    @deadlovelll
    deadlovelll
    on Sep 21, 2026
    ContributorAuthor
    More actions

    The new test fails on refleaks buildbots, see e.g. https://buildbot.python.org/#/builders/2263/builds/295

    Thank you! I'll take a look

  13. hugovk
    added 3 commits that reference this issue on Sep 22, 2026

    gh-157788: Fix `test_long_task_name_is_truncated` by not hardcoding m…

    6eedb1a

    [3.15] gh-157788: Fix `test_long_task_name_is_truncated` by not hardc…

    2b3b252

    [3.14] gh-157788: Fix `test_long_task_name_is_truncated` by not hardc…

    c77e98a
  14. encukou
    closed this as completedon Sep 22, 2026
  15. github-project-automation
    moved this from In Progress to Done in asyncioon Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • asyncio
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.