Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix memory leaks in cross-interpreter channel operations and shared
namespace handling.
2 changes: 1 addition & 1 deletion Modules/_interpchannelsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ _channelitem_clear_data(_channelitem *item, int removed)
{
if (item->data != NULL) {
// 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;
}

Expand Down
2 changes: 1 addition & 1 deletion Modules/_interpqueuesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ _queueitem_clear_data(_queueitem *item)
return;
}
// 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;
}

Expand Down
15 changes: 12 additions & 3 deletions Python/crossinterp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,8 @@ _release_xid_data(_PyXIData_t *xidata, int rawfree)
{
PyObject *exc = PyErr_GetRaisedException();
int res = rawfree
? _PyXIData_Release(xidata)
: _PyXIData_ReleaseAndRawFree(xidata);
? _PyXIData_ReleaseAndRawFree(xidata)
: _PyXIData_Release(xidata);
if (res < 0) {
/* The owning interpreter is already destroyed. */
_PyXIData_Clear(NULL, xidata);
Expand Down Expand Up @@ -1805,6 +1805,15 @@ _PyXI_InitFailureUTF8(_PyXI_failure *failure,
int
_PyXI_InitFailure(_PyXI_failure *failure, _PyXI_errcode code, PyObject *obj)
{
*failure = (_PyXI_failure){
.code = code,
.msg = NULL,
.msg_owned = 0,
};
if (obj == NULL) {
return 0;
}

PyObject *msgobj = PyObject_Str(obj);
if (msgobj == NULL) {
return -1;
Expand All @@ -1813,7 +1822,7 @@ _PyXI_InitFailure(_PyXI_failure *failure, _PyXI_errcode code, PyObject *obj)
// That happens automatically in _capture_current_exception().
const char *msg = _copy_string_obj_raw(msgobj, NULL);
Py_DECREF(msgobj);
if (PyErr_Occurred()) {
if (msg == NULL) {
return -1;
}
*failure = (_PyXI_failure){
Expand Down
Loading