python / python/cpython

LeakSanitizer detects memory leaks in test_import with _testsinglephase module in subinterpreter

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

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

pending tests topic-subinterpreters type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

LeakSanitizer detects memory leaks when running test_import with the _testsinglephase module loaded in a subinterpreter.

How to Reproduce

Build:

CC=clang CXX=clang++ ./configure --disable-optimizations --with-pydebug --with-address-sanitizer && make -j$(nproc)

Run:

./python -X dev -X showrefcount -m test test_import -j0
Leak Summary
==643791==ERROR: LeakSanitizer: detected memory leaks
SUMMARY: AddressSanitizer: 6709 byte(s) leaked in 45 allocation(s).
Code Locations

The leaks originate from:

Subinterpreter execution:

Module initialization:

Import machinery:

Leaked Objects
  • Type objects (1016 bytes × 2): via type_newPyErr_NewException
  • Dictionary keys (424 bytes × 2): via new_keys_objectPyDict_SetItemString
  • PyCMethod objects (384 bytes × 2 groups): via PyModule_AddFunctions
  • Additional: Unicode strings, tuples, dictionaries
Full Output

See attached .log files for complete LeakSanitizer output for each version.

312.log
313.log
314.log
main.log

CPython versions tested on:

3.12, 3.13, 3.14, 3.15, CPython main branch

Operating systems tested on:

Linux

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

文書化された ASan ビルドと ./python -X dev -X showrefcount -m test test_import -j0 を使ってリークを再現します。次に、Modules/_testcapimodule.crun_in_subinterp)、Modules/_testsinglephase.cinit__testsinglephase_basicinit_state)、および Python/importdl.c_PyImport_RunModInitFunc)を調べます。テストが完了し、LeakSanitizer が記載されたリークを報告しなければ完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c, python
領域
performance, testing
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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