python / python/cpython

Python 3.14 stack overflow detection is incompatible with C++ Boost make_fcontext() coroutines

未關閉
#139,653 30 則留言 12 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

3.14 interpreter-core
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Python 3.14 introduced a new stack overflow detection mecanism: InternalDocs/stack_protection.md (#130396).

The KiCad application uses C++ Boost make_fcontext() coroutines which runs coroutine in their own stack.

Code example from fcontext doc:

// context-function
void f(intptr);

// creates a new stack
std::size_t size = 8192;
void* sp(std::malloc(size));

// context fc uses f() as context function
// fcontext_t is placed on top of context stack
// a pointer to fcontext_t is returned
fcontext_t fc(make_fcontext(sp,size,f));

_Py_InitializeRecursionLimits() is called in the main thread, whereas _Py_CheckRecursiveCall() is called for the first time in a coroutine (make_fcontext()).

Problem: Python detects a stack overflow because it's not aware that the stack base address and size changed when make_fcontext() was called.

pthread functions such as pthread_attr_getguardsize() are incompatible with make_fcontext().

cc @markshannon

Linked PRs
  • gh-139667
  • gh-139668
  • gh-141551
  • gh-141661
  • gh-141711
  • gh-141892
  • gh-141944

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 InternalDocs/stack_protection.md 開始,然後追蹤來自 Boost make_fcontext() coroutine 的 _Py_InitializeRecursionLimits() 和第一次 _Py_CheckRecursiveCall()。查看連結的 PR,了解目前的方向,以及 stack-base 和 size 的轉換是否已經得到處理;完成的標準是 coroutine stack 不再觸發錯誤的 stack-overflow 偵測。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
cpp, python
領域
operating-systems
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
20/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。