python / python/mypy

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

Aperta
#12,867 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

crash topic-async topic-mypyc
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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)

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da crash.py e riproduci il problema usando mypyc, Python 3.10 e asyncio.wait_for con il timeout fornito. Ispeziona il coroutine helper generato e il percorso di throw in __native.c, insieme a CPy_CatchError in exc_ops.c, usando il traceback come punto di ingresso. Il lavoro è completato quando l’esempio minimo gestisce la cancellazione senza un segmentation fault.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
compilers
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.