python / python/cpython

`_remote_debugging`: `BinaryWriter.write_sample()` trivial segfault

Aberta
#157,227 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

extension-modules topic-profiling type-bug
Linguagem predominante
Python
Estrelas
77.2k
Forks
35.9k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

Bug report

Bug description:
[139] 2026-09-09T18:57:09.249268000+0200 maurycy@gimel /Users/maurycy/work/cpython (main 52ffffe) % ./python.exe 
Python 3.16.0a0 (heads/main:83dbe6ae9f4, Sep  6 2026, 18:18:16) [Clang 21.0.0 (clang-2100.1.1.101)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import _remote_debugging
>>> _remote_debugging.BinaryWriter("/tmp/o.bin", 1000, 1000000).write_sample([42], 2000)
zsh: segmentation fault  ./python.exe

There's many more variants, easy to come up with.

This is the place:

https://github.com/python/cpython/blob/52ffffe0a23bf0f4a57ee00377c5aeb965b3a29a/Modules/_remote_debugging/binary_io_writer.c#L1013

It only checks if it's a list, and then it trusts completely:

https://github.com/python/cpython/blob/52ffffe0a23bf0f4a57ee00377c5aeb965b3a29a/Modules/_remote_debugging/binary_io_writer.c#L841-L848

https://github.com/python/cpython/blob/52ffffe0a23bf0f4a57ee00377c5aeb965b3a29a/Modules/_remote_debugging/binary_io_writer.c#L928-L930

https://github.com/python/cpython/blob/52ffffe0a23bf0f4a57ee00377c5aeb965b3a29a/Modules/_remote_debugging/binary_io_writer.c#L1020-L1023

The comment says Use unchecked accessors since we control the data structures but I still think that segmentation fault on a public method is not great.

I will submit a PR soon.

ref #148178

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs
  • gh-157228

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece em Modules/_remote_debugging/binary_io_writer.c, em BinaryWriter.write_sample() e nos locais de unchecked-accessor referenciados. Reproduza o crash com a chamada fornecida BinaryWriter(...).write_sample([42], 2000) e, em seguida, verifique se entradas públicas inválidas não causam mais um segfault e se o comportamento está coberto por testes de regressão apropriados.

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
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.