python / python/cpython

Crash when deleting decimal.Context.rounding through the descriptor

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

Ninguém assumiu esta issue ainda.

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

Descrição

Crash report

What happened?
import decimal
decimal.Context.rounding.__delete__(decimal.Context())
Segmentation fault (core dumped)

context_setround() passes the value to getround(), which calls
PyUnicode_Check() on it without checking it for NULL, and the setter is
called with NULL when the attribute is deleted. Plain del ctx.rounding is
safe, because context_setattr() rejects deletion — but it is bypassed by
calling the descriptor.

The other five Context getsets do not crash, but raise SystemError:

import decimal
decimal.Context.prec.__delete__(decimal.Context())
# SystemError: ../Objects/longobject.c:577: bad argument to internal function

Same for Emin, Emax, capitals and clamp.

CPython versions tested on:

3.15, 3.14, 3.13, 3.12

Operating systems tested on:

Windows

Output from running 'python -VV' on the command line:

Python 3.12.3 (main, Jan 8 2026, 11:30:50) [GCC 13.3.0] / Python 3.14.2 (main, Dec 17 2025, 21:10:36) [MSC v.1944 64 bit (AMD64)]

Linked PRs
  • gh-156807

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 com decimal.Context.rounding.delete e rastreie o caminho do descritor por meio de context_setround(), getround() e context_setattr(). Compare o comportamento da exclusão entre rounding, prec, Emin, Emax, capitals e clamp; considera-se concluído quando a exclusão do descritor não causar mais uma falha nem gerar um SystemError não intencional. O PR vinculado gh-156807 indica que o trabalho já está em andamento.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
backend
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
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.