python / python/mypy

Segmentation fault when native coroutine compiled with mypyc is cancelled due to timeout

Offen
#12,867 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

crash topic-async topic-mypyc
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Crash Report
Segmentation fault encountered with a mypyc compiled coroutine that was cancelled due to timeout when being invoked via asyncio.wait_for.

Traceback

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   Python                        	       0x1009af3eb PyException_SetTraceback + 107
1   crash.cpython-310-darwin.so   	       0x1011b1c8f CPy_CatchError + 127 (exc_ops.c:60)
2   crash.cpython-310-darwin.so   	       0x1011b472a CPyDef_crash_gen_____mypyc_generator_helper__ + 202 (__native.c:517)
3   crash.cpython-310-darwin.so   	       0x1011b55e8 CPyDef_crash_gen___throw + 23 (__native.c:938) [inlined]
4   crash.cpython-310-darwin.so   	       0x1011b55e8 CPyPy_crash_gen___throw + 152 (__native.c:984)
5   Python                        	       0x1009aceba method_vectorcall_FASTCALL_KEYWORDS + 170
6   Python                        	       0x1009a4cb5 PyObject_VectorcallMethod + 149
7   _asyncio.cpython-310-darwin.so	       0x100ef1563 task_step + 515
8   _asyncio.cpython-310-darwin.so	       0x100ef2b5b task_wakeup + 267
9   Python                        	       0x1009e9a18 cfunction_vectorcall_O + 280
10  Python                        	       0x100ab031a context_run + 250
11  Python                        	       0x1009e97c4 cfunction_vectorcall_FASTCALL_KEYWORDS + 132
12  Python                        	       0x100a90384 _PyEval_EvalFrameDefault + 28404
13  Python                        	       0x100a89362 _PyEval_Vector + 146
14  Python                        	       0x100a936ee call_function + 430
15  Python                        	       0x100a8ffbb _PyEval_EvalFrameDefault + 27435
16  Python                        	       0x100a89362 _PyEval_Vector + 146
17  Python                        	       0x100a936ee call_function + 430
18  Python                        	       0x100a8ffbb _PyEval_EvalFrameDefault + 27435
19  Python                        	       0x100a89362 _PyEval_Vector + 146
20  Python                        	       0x100a936ee call_function + 430
21  Python                        	       0x100a8ffbb _PyEval_EvalFrameDefault + 27435
22  Python                        	       0x100a89362 _PyEval_Vector + 146
23  Python                        	       0x100a936ee call_function + 430
24  Python                        	       0x100a8ffbb _PyEval_EvalFrameDefault + 27435
25  Python                        	       0x100a89362 _PyEval_Vector + 146
26  Python                        	       0x100a936ee call_function + 430
27  Python                        	       0x100a8ffe7 _PyEval_EvalFrameDefault + 27479
28  Python                        	       0x100a89362 _PyEval_Vector + 146
29  Python                        	       0x100a892b8 PyEval_EvalCode + 120
30  Python                        	       0x100addcb4 PyRun_StringFlags + 244
31  Python                        	       0x100addb75 PyRun_SimpleStringFlags + 69
32  Python                        	       0x100afd78f Py_RunMain + 463
33  Python                        	       0x100afe27f pymain_main + 335
34  Python                        	       0x100afe2db Py_BytesMain + 43
35  dyld                          	       0x1026de4fe start + 462


To Reproduce
A minimal example to reproduce the seg fault is:

crash.py

import asyncio

async def crash()->None:
    await asyncio.sleep(1)
mypyc crash.py
python -c "import asyncio; import crash; asyncio.run(asyncio.wait_for(crash.crash(), timeout=0.1))"

Your Environment

  • Mypy version used: mypy 0.950 (compiled: yes)
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.10.4
  • Operating system and version: Originally encountered on macOS 12.1 (21C52)

Beitragsleitfaden

Beitragsleitfaden öffnen

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 mit crash.py und reproduziere den Fehler mit mypyc, Python 3.10 und asyncio.wait_for unter Verwendung des bereitgestellten Timeouts. Untersuche den generierten Coroutine-Helfer und den throw-Pfad in __native.c sowie CPy_CatchError in exc_ops.c, wobei der Traceback als Einstiegspunkt dient. Erledigt ist die Aufgabe, wenn das Minimalbeispiel die Cancellation ohne einen segmentation fault verarbeitet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

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