GH-118095: Make invalidating and clearing executors memory safe (GH-118459)

This commit is contained in:
Mark Shannon 2024-05-01 11:34:50 +01:00 committed by GitHub
parent 21c09d9f81
commit f6fab21721
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 103 additions and 42 deletions

View file

@ -1504,7 +1504,8 @@ clear_executors(PyCodeObject *co)
assert(co->co_executors);
for (int i = 0; i < co->co_executors->size; i++) {
if (co->co_executors->executors[i]) {
_Py_ExecutorClear(co->co_executors->executors[i]);
_Py_ExecutorDetach(co->co_executors->executors[i]);
assert(co->co_executors->executors[i] == NULL);
}
}
PyMem_Free(co->co_executors);