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 摘要。