Skip to content

Commit 3c81475

Browse files
committed
Backport python#122834 for 3.13
1 parent 84c8cd0 commit 3c81475

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed double-free when using :func:`gc.get_referents` with a freed
2+
:class:`asyncio.Future` iterator.

Modules/_asynciomodule.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3530,16 +3530,8 @@ module_traverse(PyObject *mod, visitproc visit, void *arg)
35303530

35313531
Py_VISIT(state->context_kwname);
35323532

3533-
#ifndef Py_GIL_DISABLED
3534-
// Visit freelist.
3535-
PyObject *next = (PyObject*) state->fi_freelist;
3536-
while (next != NULL) {
3537-
PyObject *current = next;
3538-
Py_VISIT(current);
3539-
next = (PyObject*) ((futureiterobject*) current)->future;
3540-
}
3541-
#endif
3542-
3533+
// GH-122695: Do not traverse the freelist here, as that can cause problems
3534+
// with gc.get_referents()
35433535
return 0;
35443536
}
35453537

0 commit comments

Comments
 (0)