`python -m asyncio ps` fails if any task name is longer than 255 characters
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
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
- gh-157843
- gh-157826
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece em object_reading.c e reproduza a falha com o exemplo fornecido de nome de tarefa do asyncio, usando python -m asyncio ps ou a chamada mostrada a RemoteUnwinder. Está concluído quando a chamada tem sucesso se o nome de uma tarefa exceder 255 caracteres e o nome retornado for truncado para 255 caracteres; verifique o PR vinculado gh-157790 para consultar o trabalho já em andamento.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- c, python
- Domínio
- devtools
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 30/100