Summary When running _testembed under LeakSanitizer, test_initconfig_get_api reports a memory leak.
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Programs/_testembed.c 中的 test_initconfig_get_api 開始,檢視報告中描述的 PyInitConfig_GetStrList 結果和組態生命週期。執行提供的 sanitizer 建置以及 ./Programs/_testembed test_initconfig_get_api;當測試完成且 LeakSanitizer 未回報直接或相關的組態洩漏時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c, python
- 領域
- testing
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100