python / python/cpython

Summary When running _testembed under LeakSanitizer, test_initconfig_get_api reports a memory leak.

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

Ninguém assumiu esta issue ainda.

tests topic-C-API 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:
Summary

When running _testembed under LeakSanitizer,
test_initconfig_get_api reports a memory leak.

Reproducer

Build CPython with sanitizers:

./configure \
  --with-pydebug \
  --with-address-sanitizer \
  --with-undefined-behavior-sanitizer
make -j

Run the specific test:

ASAN_OPTIONS=detect_leaks=1 \
./Programs/_testembed test_initconfig_get_api
Observed result

LeakSanitizer reports:

ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1 byte(s) in 1 object(s) allocated from:
    #0  malloc
    #1  PyInitConfig_GetStrList Python/initconfig.c:4024
    #2  test_initconfig_get_api Programs/_testembed.c:1844
Root cause

In test_initconfig_get_api:

  1. The initial call to
PyInitConfig_GetStrList(config, "xoptions", &length, &items)

returns an empty list (length == 0).

  1. The returned items buffer was not freed.
  2. The PyInitConfig *config created by PyInitConfig_Create() was not released before returning.

Under LeakSanitizer, this results in a small direct leak and indirect leaks associated with the configuration lifetime.

Environment
  • Architecture: aarch64-linux-gnu

  • Built with: --with-address-sanitizer

  • Leak detected via: ASAN_OPTIONS=detect_leaks=1

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-145206

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 Programs/_testembed.c, em test_initconfig_get_api, e revise o resultado de PyInitConfig_GetStrList e o tempo de vida da configuração descrito no relatório. Execute o build com sanitizer fornecido e ./Programs/_testembed test_initconfig_get_api; está concluído quando o teste termina sem que o LeakSanitizer reporte vazamentos diretos ou associados da configuração.

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

Avaliação

Stack de tecnologia
c, python
Domínio
testing
Tipo de issue
Bug
Dificuldade
2/5
Tempo estimado
1-3 horas
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.