python / python/cpython

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

オープン
#145,204 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

tests topic-C-API type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
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:

  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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。