Skip to content

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

Open
@alisaifee

Description

@alisaifee

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)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions