python / python/cpython

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

Abierto
#139,653 30 comentarios 12 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

3.14 interpreter-core
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con InternalDocs/stack_protection.md y luego sigue _Py_InitializeRecursionLimits() y la primera llamada a _Py_CheckRecursiveCall() desde una coroutine de Boost make_fcontext(). Revisa los PRs enlazados para entender la dirección actual y si la transición de la base y el tamaño de la pila ya está abordada; se considera terminado cuando las pilas de las coroutines ya no activan una detección falsa de desbordamiento de pila.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
cpp, python
Área
operating-systems
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
20/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.