mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.13] gh-140306: Fix memory leaks in cross-interpreter data handling (GH-140307) (GH-140357)
(cherry picked from commit f9323213c9)
Co-authored-by: Shamil <ashm.tech@proton.me>
This commit is contained in:
parent
e5ebcabc6b
commit
d7473f7a47
4 changed files with 6 additions and 4 deletions
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix memory leaks in cross-interpreter channel operations and shared
|
||||||
|
namespace handling.
|
||||||
|
|
@ -562,7 +562,7 @@ _channelitem_clear_data(_channelitem *item, int removed)
|
||||||
{
|
{
|
||||||
if (item->data != NULL) {
|
if (item->data != NULL) {
|
||||||
// It was allocated in channel_send().
|
// It was allocated in channel_send().
|
||||||
(void)_release_xid_data(item->data, XID_IGNORE_EXC & XID_FREE);
|
(void)_release_xid_data(item->data, XID_IGNORE_EXC | XID_FREE);
|
||||||
item->data = NULL;
|
item->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -435,7 +435,7 @@ _queueitem_clear_data(_queueitem *item)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// It was allocated in queue_put().
|
// It was allocated in queue_put().
|
||||||
(void)_release_xid_data(item->data, XID_IGNORE_EXC & XID_FREE);
|
(void)_release_xid_data(item->data, XID_IGNORE_EXC | XID_FREE);
|
||||||
item->data = NULL;
|
item->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -455,8 +455,8 @@ _release_xid_data(_PyCrossInterpreterData *data, int rawfree)
|
||||||
{
|
{
|
||||||
PyObject *exc = PyErr_GetRaisedException();
|
PyObject *exc = PyErr_GetRaisedException();
|
||||||
int res = rawfree
|
int res = rawfree
|
||||||
? _PyCrossInterpreterData_Release(data)
|
? _PyCrossInterpreterData_ReleaseAndRawFree(data)
|
||||||
: _PyCrossInterpreterData_ReleaseAndRawFree(data);
|
: _PyCrossInterpreterData_Release(data);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
/* The owning interpreter is already destroyed. */
|
/* The owning interpreter is already destroyed. */
|
||||||
_PyCrossInterpreterData_Clear(NULL, data);
|
_PyCrossInterpreterData_Clear(NULL, data);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue