gh-140431: Fix GC crash due to partially initialized coroutines (gh-1… · python/cpython@574405c

GitHub

File tree

Misc/NEWS.d/next/Core_and_Builtins

Objects

Original file line numberDiff line numberDiff line change@@ -0,0 +1,3 @@

1+Fix a crash in Python's :term:`garbage collector <garbage collection>` due to

2+partially initialized :term:`coroutine` objects when coroutine origin tracking

3+depth is enabled (:func:`sys.set_coroutine_origin_tracking_depth`).

Original file line numberDiff line numberDiff line change@@ -932,6 +932,7 @@ make_gen(PyTypeObject *type, PyFunctionObject *func)

932932gen->gi_weakreflist=NULL;

933933gen->gi_exc_state.exc_value=NULL;

934934gen->gi_exc_state.previous_item=NULL;

935+gen->gi_iframe.f_executable=PyStackRef_None;

935936assert(func->func_name!=NULL);

936937gen->gi_name=Py_NewRef(func->func_name);

937938assert(func->func_qualname!=NULL);