Commit e5a86777 authored by Stefan Behnel's avatar Stefan Behnel

hopefully fix crash where Coroutine deallocation could execute Python code to...

hopefully fix crash where Coroutine deallocation could execute Python code to print a warning which could trigger GC and hit the dead Coroutine object
parent 278fc91f
...@@ -1094,6 +1094,8 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) { ...@@ -1094,6 +1094,8 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) {
__pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
if (gen->resume_label == 0 && !PyErr_Occurred()) { if (gen->resume_label == 0 && !PyErr_Occurred()) {
// untrack dead object as we are executing Python code (which might trigger GC)
PyObject_GC_UnTrack(self);
#if PY_VERSION_HEX >= 0x03030000 || defined(PyErr_WarnFormat) #if PY_VERSION_HEX >= 0x03030000 || defined(PyErr_WarnFormat)
PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname); PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname);
#else #else
...@@ -1140,6 +1142,7 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) { ...@@ -1140,6 +1142,7 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) {
PyErr_WriteUnraisable(self); PyErr_WriteUnraisable(self);
Py_XDECREF(msg); Py_XDECREF(msg);
#endif #endif
PyObject_GC_Track(self);
} }
__Pyx_Coroutine_dealloc(self); __Pyx_Coroutine_dealloc(self);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment