* Backport #122834 for 3.13
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')
--- /dev/null
+Fixed double-free when using :func:`gc.get_referents` with a freed
+:class:`asyncio.Future` iterator.
Py_VISIT(state->iscoroutine_typecache);
Py_VISIT(state->context_kwname);
-
-#ifndef Py_GIL_DISABLED
- // Visit freelist.
- PyObject *next = (PyObject*) state->fi_freelist;
- while (next != NULL) {
- PyObject *current = next;
- Py_VISIT(current);
- next = (PyObject*) ((futureiterobject*) current)->future;
- }
-#endif
-
return 0;
}