[BUG]: PyObject_Type resource leak
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 include/pybind11/typing.h 第 101 行附近开始,检查 PYBIND11_OBJECT_DEFAULT(..., PyObject_Type) 对 typing::Union、Optional、Final、ClassVar、Literal 和 TypeVar 的声明,并将它们的 check_ 实现与较新的 typing::Object 进行比较。该 issue 已经指出了泄漏:PyObject_Type 返回一个新的强引用,而 check_ 将其丢弃。先阅读周围的宏定义,然后验证这些 check_ 路径不再留下无主引用,与 h.ptr() != nullptr 的方式保持一致。完成意味着参数加载不再泄漏类型引用。
由索引模型根据 Issue 内容生成。
描述
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
a3954715fe849519754abded4d572bf7edab67e3
Problem description
PyObject_Type returns a new strong reference to the object's type object which is never decrefed by the check or check_ functions.
https://docs.python.org/3/c-api/object.html#c.PyObject_Type
@InvincibleRMC it looks like you implemented these. What was the intent with the PyObject_Type check?
AI generated text from #6285
include/pybind11/typing.h:101: each argument load of typing::Union, Optional, Final, ClassVar, Literal or TypeVar leaks one reference to the type of the argument.
- These classes use PYBIND11_OBJECT_DEFAULT(..., PyObject_Type), and check_ discards the new reference that PyObject_Type returns.
- Fix: use the same check_ as the new typing::Object (h.ptr() != nullptr).
Reproducible example code
Is this a regression? Put the last known working version here if it is.
Not a regression
- 主要语言
- C++
- 星标
- 18k
- 派生
- 2.3k
- 平均合并
- 5 天 7 小时
- 30 天内合并 PR
- 53
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pybind/pybind11 的其他 Issue
-
triage
难度 1/5 1 小时以内 新手友好度 62/100
pybind/pybind11#5604 · 1 条评论 ·
维护者通常 3 天内回复
-
triage
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 3 天内回复
-
docs
难度 2/5 1-3 小时 新手友好度 60/100
维护者通常 3 天内回复
-
array_t::at() returns a misaligned reference when the stride is not a multiple of alignof(T)可能已有人在做 @henryiii 今天认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 3 天内回复
-
难度 3/5 1-2 天 新手友好度 40/100
维护者通常 3 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
patrick-hudson/put.gd-desktop#2044 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
uxlfoundation/oneDNN#6604 · 1 条评论 ·
维护者通常 2 天内回复
-
[Bug]: RoundToNearest truncates in plugins compiled with spcomp 1.13可能已有人在做 @fmu1337 今天认领。 未关闭Bug
难度 2/5 1-3 小时 新手友好度 62/100
alliedmodders/sourcemod#2627 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 75/100
维护者通常 1 天内回复