8000 bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). by ericsnowcurrently · Pull Request #12360 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). #12360

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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Make a copy of data-to-be-deleted.
  • Loading branch information
ericsnowcurrently committed Apr 5, 2019
commit 279ff04bf1072d422cbe5b9230ecc558c70f9ec0
13 changes: 11 additions & 2 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,7 @@ _release_xidata(void *arg)
data->free(data->data);
}
Py_XDECREF(data->obj);
PyMem_Free(data);
return 0;
}

Expand All @@ -1381,14 +1382,22 @@ _PyCrossInterpreterData_Release(_PyCrossInterpreterData *data)
}
return;
}
// XXX There's a slight race here...
// XXX There's an ever-so-slight race here...
if (interp->finalizing) {
// XXX Someone leaked some memory...
return;
}

// "Release" the data and/or the object.
if (_Py_AddPendingCall(interp, 0, _release_xidata, data) != 0) {
_PyCrossInterpreterData *copied = PyMem_Malloc(sizeof(_PyCrossInterpreterData));
if (copied == NULL) {
PyErr_SetString(PyExc_MemoryError,
"Not enough memory to preserve cross-interpreter data");
PyErr_Print();
return;
}
memcpy(copied, data, sizeof(_PyCrossInterpreterData));
if (_Py_AddPendingCall(interp, 0, _release_xidata, copied) != 0) {
// XXX Queue full or couldn't get lock. Try again somehow?
}
}
Expand Down
0