Summary When running _testembed under LeakSanitizer, test_initconfig_get_api reports a memory leak.
Ninguém assumiu esta issue ainda.
- 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:
- The initial call to
PyInitConfig_GetStrList(config, "xoptions", &length, &items)
returns an empty list (length == 0).
- The returned items buffer was not freed.
- 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
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 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