`python -m asyncio ps` fails if any task name is longer than 255 characters
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
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-157790
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu trong object_reading.c và tái hiện lỗi bằng ví dụ tên task của asyncio được cung cấp, sử dụng python -m asyncio ps hoặc lệnh gọi RemoteUnwinder được示. Hoàn thành khi lệnh gọi thành công nếu tên task vượt quá 255 ký tự và tên được trả về bị cắt còn 255 ký tự; kiểm tra PR được liên kết gh-157790 để xem công việc đang được thực hiện.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, python
- Lĩnh vực
- devtools
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 30/100