Segfault decoding a TypedDict that references a recursive TypedDict which failed to build
维护者通常 1 天内回复
评估
调研方向
Start by reading the TypedDict construction and cache cleanup paths, then trace the JSON decode and dict conversion paths described in the report. Reproduce the example with the recursive A and B TypedDicts and check how failed construction leaves references to partial metadata. Done means decoding no longer segfaults and conversion validates required fields after A fails to build.
由索引模型根据 Issue 内容生成。
描述
Description
from typing import NotRequired, TypedDict
import msgspec
class A(TypedDict):
child: NotRequired["B"]
bad: list | tuple # unsupported, A fails to build
class B(TypedDict):
parent: A
try:
msgspec.convert({}, A)
except TypeError:
pass
msgspec.convert({"parent": {}}, B) # {'parent': {}}: A's required `bad` is not checked
msgspec.json.decode(b'{"parent": {"x": 1}}', type=B) # segfault
A caches its TypedDictInfo before building its fields, so that recursive types work. B is built during that window and keeps a reference to the partial info (nrequired == -1, NULL keys). When A fails, only A's cache is removed. The decode paths dereference the NULL keys, and the dict path never checks nrequired.
- 主要语言
- Python
- 星标
- 4.2k
- 派生
- 216
- 平均合并
- 2 天 21 小时
- 30 天内合并 PR
- 53
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
msgspec/msgspec 的其他 Issue
-
难度 5/5 一周以上 新手友好度 35/100
msgspec/msgspec#1288 · 1 条评论 ·
维护者通常 1 天内回复
-
Segfault reading decimal_format after a failed Encoder.__init__ re-call可能已有人在做 @digit50 于 4 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 62/100
msgspec/msgspec#1279 · 4 条评论 ·
维护者通常 1 天内回复
-
Fix Free-Threading support可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭enhancement
难度 5/5 一周以上 新手友好度 25/100
msgspec/msgspec#1249 · 2 条评论 ·
维护者通常 1 天内回复
-
convert: mapping fields named like mapping methods (keys, get, ...) resolve to the bound method可能已有人在做 @MbappeWU 于 6 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
维护者通常 1 天内回复
-
Decoding subnormal numbers is really slow可能已有人在做 @arindamsikder 于 12 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
msgspec/msgspec#1232 · 5 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
mohitmishra786/readprism#322 ·
维护者通常 1 天内回复
-
good first issue
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 1/5 1 小时以内 新手友好度 75/100
维护者通常 1 天内回复
-
API-key credentials accept a blank key: empty via the API, spaces-only via the builder's Add API key dialog可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 77/100
Significant-Gravitas/AutoGPT#15727 ·
维护者通常 1 天内回复