MagicStack / MagicStack/uvloop

Spawning a subprocess crashes the interpreter if subinterpreters exist

Ouverte
#650 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

bug
Langage dominant
Cython
Étoiles
11.9k
Forks
616
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

  • uvloop version: 0.21.0
  • Python version: 3.13.0
  • Platform: Linux
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes
  • Does uvloop behave differently from vanilla asyncio? How?: vanilla asyncio doesn't crash

MWE:

import asyncio

import _interpreters as interpreters
import uvloop

async def main():
    interp_id = interpreters.create()
    await asyncio.create_subprocess_exec("sleep", "2")
    interpreters.destroy(interp_id)  # this is never reached


asyncio.run(main(), loop_factory=uvloop.new_event_loop)

Crash log:

Fatal Python error: PyThreadState_Get: the function must be called with the GIL held, after Python initialization and before Python finalization, but the GIL is released (the current Python thread state is NULL)
Python runtime state: initialized

Current thread 0x00007fa5713c8740 (most recent call first):
  File "/usr/lib64/python3.13/asyncio/subprocess.py", line 224 in create_subprocess_exec
  File "/home/alex/workspace/anyio/bug-trio.py", line 8 in main
  File "/usr/lib64/python3.13/asyncio/runners.py", line 118 in run
  File "/usr/lib64/python3.13/asyncio/runners.py", line 194 in run
  File "/home/alex/workspace/anyio/bug-trio.py", line 12 in <module>

Extension modules: uvloop.loop (total: 1)

If I destroy the subinterpreter before spawning the subprocess, it works fine.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par exécuter la MWE fournie avec uvloop 0.21.0 et Python 3.13.0 sous Linux, puis comparez-la avec vanilla asyncio. Inspectez le chemin du sous-processus impliquant uvloop.new_event_loop et uvloop.loop, en utilisant la ligne 224 de asyncio/subprocess.py et le crash signalé comme critères de reproduction et d'achèvement.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
backend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.