Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Lib/test/test_asyncio/test_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,14 @@ def test_future_del_segfault(self):
with self.assertRaises(AttributeError):
del fut._log_traceback

def test_future_iter_get_referents_segfault(self):
# See https://github.com/python/cpython/issues/122695
import _asyncio
it = iter(self._new_future(loop=self.loop))
del it
evil = gc.get_referents(_asyncio)
gc.collect()


@unittest.skipUnless(hasattr(futures, '_CFuture'),
'requires the C _asyncio module')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed double-free when using :func:`gc.get_referents` with a freed
:class:`asyncio.Future` iterator.
8 changes: 0 additions & 8 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3606,14 +3606,6 @@ module_traverse(PyObject *mod, visitproc visit, void *arg)
Py_VISIT(state->iscoroutine_typecache);

Py_VISIT(state->context_kwname);

// Visit freelist.
PyObject *next = (PyObject*) state->fi_freelist;
while (next != NULL) {
PyObject *current = next;
Py_VISIT(current);
next = (PyObject*) ((futureiterobject*) current)->future;
}
return 0;
}

Expand Down
Loading