Segfault at exit when calling `sys.activate_stack_trampoline("perf")` after loading a native library
未關閉
還沒有人認領這個 Issue。
interpreter-core
type-crash
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 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