Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-115874: Fix segfault in FutureIter_dealloc #117741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 19, 2024
Merged
Changes from 3 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
14 changes: 12 additions & 2 deletions 14 Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1601,11 +1601,21 @@ static void
FutureIter_dealloc(futureiterobject *it)
{
PyTypeObject *tp = Py_TYPE(it);
asyncio_state *state = get_asyncio_state_by_def((PyObject *)it);

assert(_PyType_HasFeature((PyTypeObject *)tp, Py_TPFLAGS_HEAPTYPE));
savannahostrowski marked this conversation as resolved.
Show resolved Hide resolved
savannahostrowski marked this conversation as resolved.
Show resolved Hide resolved

PyHeapTypeObject *ht = (PyHeapTypeObject*)tp;
PyObject *module = ht->ht_module;
savannahostrowski marked this conversation as resolved.
Show resolved Hide resolved
asyncio_state *state = NULL;

PyObject_GC_UnTrack(it);
tp->tp_clear((PyObject *)it);

if (state->fi_freelist_len < FI_FREELIST_MAXLEN) {
if (module && _PyModule_GetDef(module) == &_asynciomodule) {
brandtbucher marked this conversation as resolved.
Show resolved Hide resolved
state = get_asyncio_state(module);
}

if (state && state->fi_freelist_len < FI_FREELIST_MAXLEN) {
state->fi_freelist_len++;
it->future = (FutureObj*) state->fi_freelist;
state->fi_freelist = it;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.