python / python/cpython

`test_free_threading.test_monitoring` flaky (occasional reference leak)

未关闭
#136,692 8 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

3.13 3.14 3.15 tests topic-free-threading type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

When running ./python -E -m test --timeout=2700 -R3:3 -u-cpu -j40 test_free_threading.test_monitoring -F, I get a failure every ~50-100 test runs:

0:00:36 load avg: 122.12 [ 55/1] test_free_threading.test_monitoring failed (reference leak)
beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more)
123:456
XX. 243
test_free_threading.test_monitoring leaked [2, 4, 3] memory blocks, sum=9

I think the issue is that we rely on Thread.is_alive() instead of joining the threads. I think there are still some objects that may not be freed until the thread is joined (like the handle):

https://github.com/python/cpython/blob/cb59eaefeda5ff44ac0c742bff2b8afc023be313/Lib/test/test_free_threading/test_monitoring.py#L65-L77

Linked PRs
  • gh-136896
  • gh-141832

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Lib/test/test_free_threading/test_monitoring.py 第 65-77 行附近开始,使用报告中的命令重现泄漏。检查其中的线程清理,然后重新运行重复测试,以确认不再发生引用泄漏;链接的 PR gh-136896 和 gh-141832 表明这项工作已经转移到其他地方。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
operating-systems, testing-qa
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。