Possible `NULL`-related `SystemError` when interpreter is not fully initialized

Aberta
#161,863 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
65/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
c, python
Domínio
backend

Direção de pesquisa

Read Python/import.c around lines 3921–3922 and the IMPORTLIB(interp) definition around lines 95–96 to understand how the null value reaches this path. Reproduce with the _freeze_module command shown in the issue, then check the error handling and tests for this import path. Done means the incomplete initialization case reports a clear SystemError explaining that imports are not fully initialized; the issue also mentions fixing freeze later.

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

Descrição

interpreter-core topic-importlib type-bug

Code: https://github.com/python/cpython/blob/9f386367333f7845095d764fad3ad9b397d04672/Python/import.c#L3921-L3922

Here IMPORTLIB(interp) can be NULL under rare conditions:

https://github.com/python/cpython/blob/9f386367333f7845095d764fad3ad9b397d04672/Python/import.c#L95-L96

For example, when interpreter is not yet fully initialized.

Output:

» ./Programs/_freeze_module crash crash.py crash.h
Exception ignored in the internal traceback machinery:
SystemError: null argument to internal routine
# ...

Refs https://github.com/python/cpython/pull/161860 where I first found this case.
Refs https://github.com/python/cpython/issues/142662 where the initial reproducer was found.

I guess we should raise a different SystemError here with the text that imports are not yet fully initialized.

My proposal is to make the error message better here: it should state the interpreter is not fully initialized.

And ideally we can fix the freeze command as well later.

Linguagem predominante
Python
Estrelas
78.2k
Forks
36.6k
Merge médio
19h 57min
PRs com merge (30d)
630

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

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.

Mais de python/cpython

Todas as issues de python/cpython

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

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