python / python/cpython

pylifecycle.c: Multiple init/fini cleanup bugs

未關閉
#149,630 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

interpreter-core type-bug
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:

Parent: https://github.com/python/cpython/issues/146102

https://gist.github.com/devdanzin/b022ff2d1304a4b2b8d3d8750abd8da5

pylifecycle.c: Multiple init/fini cleanup bugs

Summary

5 bugs in interpreter lifecycle:

  1. new_interpreter (line 2534): return status bypasses switch-back after save_tstate detach → thread state corruption.
  2. pycore_init_builtins (line 860): Direct return leaks bimod ref.
  3. add_main_module (line 2762): bimod/loader refs leaked on PyDict_SetItemString failure.
  4. finalize_clear_modules_dict (line 1685): Return value of PyObject_CallMethodNoArgs never DECREF'd.
  5. init_sys_streams (line 3019-3031): Unchecked PySys_SetObject for stdin/stdout (stderr correctly checked).
CPython versions tested on:

CPython main branch, 3.15

Operating systems tested on:

No response

Linked PRs
  • gh-149631

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先從父 issue 和連結的 gist 開始,然後檢查 pylifecycle.c 中的 new_interpreter、pycore_init_builtins、add_main_module、finalize_clear_modules_dict 和 init_sys_streams。檢查每條回報的失敗路徑,並使用連結的 PR gh-149631 了解現有內容。完成標準是處理好全部五個 lifecycle 清理問題,同時不引入新的參照或 thread-state 問題。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
c, python
領域
compilers
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。