Segfault at exit when calling `sys.activate_stack_trampoline("perf")` after loading a native library
未关闭
还没有人认领这个 Issue。
interpreter-core
type-crash
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Crash report
What happened?
import sys, ctypes
ctypes.CDLL(None)
sys.activate_stack_trampoline("perf")
sys.activate_stack_trampoline("perf")
sys.activate_stack_trampoline("perf")
100% reproducible on 3.13.12, exits cleanly on 3.13.11.
Same between 3.14.3 and 3.14.2
Things of note:
- The crash occurs during interpreter finalization, not at the point of the call
- No exception is raised;
is_stack_trampoline_active()returnsTrueafter each call - Without
ctypes.CDLL, 3 calls don't crash (but 10 calls do crash with "no more code watcher IDs available" + segfault) - 2 calls +
ctypes.CDLLdoesn't crash; 3 calls is the threshold
Repeated calls to activate_stack_trampoline("perf") when the trampoline is already active should either be a no-op or raise an error.
CPython versions tested on:
3.13, 3.14
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.13.12 (main, Mar 10 2026, 18:17:38) [Clang 21.1.4 ]
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先在 CPython 3.13.12 和 3.14.3 上运行提供的 Python 复现程序,然后跟踪 sys.activate_stack_trampoline("perf") 的实现直至解释器终结。检查重复激活如何与 ctypes.CDLL(None) 交互,并验证重复调用要么变成 no-op,要么引发错误,且不会在关闭时发生 segfault。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100