MagicStack / MagicStack/uvloop

Python 3.13 Error Walking Stack w/ PYTHONASYNCIODEBUG=1

Offen
#730 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Cython
Sterne
11.9k
Forks
616
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

There appears to be a bug in uvloop for python 3.13 walking the stack when PYTHONASYNCIODEBUG=1 and there are c frames in the stack.

I suspect this is tied to changes in 3.13 with how [python handles frames ](https://docs.python.org/3/whatsnew/3.13.html#whatsnew313-locals-semantics)

To Repro:
Python 3.13
uvloop 0.22.1 (also confirmed it happens

run: `docker build -f Dockerfile.latest -t crash-test-latest . 2>&1 | tail -3 && echo "---" && docker run --rm crash-test-latest 2>&1; echo "exit: $?"`
exits w/ 139

If you go into the dockerfile and set `ENV PYTHONASYNCIODEBUG=` (instead of 1), exits w/ 0

Dockerfile:
```
FROM python:3.13-slim
RUN pip install uvloop==0.22.1
ENV PYTHONASYNCIODEBUG=1
COPY repro.py /repro.py
CMD ["python3", "/repro.py"]
```

Repro.py
```
import asyncio
import sys
import os

print(f"Python: {sys.version}")
print(f"Platform: {sys.platform}")
print(f"PYTHONASYNCIODEBUG: {os.environ.get('PYTHONASYNCIODEBUG', '')}")

import uvloop
print(f"uvloop: {uvloop.__version__}")

async def gen():
yield 1
yield 2

async def main():
x = gen()
await x.__anext__()
# x goes out of scope on function exit

uvloop.install()
asyncio.run(main())
print("NO CRASH")
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die bereitgestellte Docker-Reproduktion aus Dockerfile.latest mit repro.py unter Python 3.13 und PYTHONASYNCIODEBUG=1 auszuführen, und vergleiche sie anschließend mit der Umgebung, in der die Variable nicht gesetzt ist. Verfolge den Fehler beim Durchlaufen des Stacks, der den asynchronen Generator und C-Frames betrifft; abgeschlossen ist die Aufgabe, wenn die Reproduktion mit aktiviertem Debug-Modus erfolgreich beendet wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
backend, networking
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.