python / python/cpython

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

オープン
#139,653 コメント 30 件 リアクション 12 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

InternalDocs/stack_protection.md から始め、Boost make_fcontext() coroutine からの _Py_InitializeRecursionLimits() と最初の _Py_CheckRecursiveCall() を追跡します。リンクされた PR を確認して現在の方向性と、stack-base と size の移行がすでに対処されているかを把握します。完了の条件は、coroutine のスタックが誤った stack-overflow 検出を引き起こさなくなることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
cpp, python
領域
operating-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。