8000 gh-76785: Use Pending Calls When Releasing Cross-Interpreter Data by ericsnowcurrently · Pull Request #109556 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-76785: Use Pending Calls When Releasing Cross-Interpreter Data #109556

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 11 commits into from
Sep 19, 2023
Merged
Prev Previous commit
Next Next commit
Do not bother freeing the data if not set.
  • Loading branch information
ericsnowcurrently committed Sep 9, 2023
commit daa7f32d4b8d8cdd448638c44bea5a8dd6d56e01
14 changes: 10 additions & 4 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2263,10 +2263,16 @@ _xidata_init(_PyCrossInterpreterData *data)
static inline void
_xidata_clear(_PyCrossInterpreterData *data)
{
if (data->free != NULL) {
data->free(data->data);
// _PyCrossInterpreterData only has two members that need to be
// cleaned up, if set: "data" must be freed and "obj" must be decref'ed.
// In both cases the original (owning) interpreter must be used,
// which is the caller's responsibility to ensure.
if (data->data != NULL) {
if (data->free != NULL) {
data->free(data->data);
}
data->data = NULL;
}
data->data = NULL;
Py_CLEAR(data->obj);
}

Expand Down Expand Up @@ -2442,7 +2448,7 @@ _call_in_interpreter(PyInterpreterState *interp, releasefunc func, void *arg)
int
_PyCrossInterpreterData_Release(_PyCrossInterpreterData *data)
{
if (data->free == NULL && data->obj == NULL) {
if ((data->data == NULL || data->free == NULL) && data->obj == NULL) {
// Nothing to release!
data->data = NULL;
return 0;
Expand Down
0