]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-140306: Fix memory leaks in cross-interpreter data handling (GH-140307...
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 20 Oct 2025 10:13:15 +0000 (13:13 +0300)
committerGitHub <noreply@github.com>
Mon, 20 Oct 2025 10:13:15 +0000 (10:13 +0000)
(cherry picked from commit f9323213c98c9f1f7f3bf5af883b73047432fe50)

Co-authored-by: Shamil <ashm.tech@proton.me>
Misc/NEWS.d/next/Core and Builtins/2025-10-18-21-29-45.gh-issue-140306.xS5CcS.rst [new file with mode: 0644]
Modules/_interpchannelsmodule.c
Modules/_interpqueuesmodule.c
Python/crossinterp.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2025-10-18-21-29-45.gh-issue-140306.xS5CcS.rst b/Misc/NEWS.d/next/Core and Builtins/2025-10-18-21-29-45.gh-issue-140306.xS5CcS.rst
new file mode 100644 (file)
index 0000000..2178c49
--- /dev/null
@@ -0,0 +1,2 @@
+Fix memory leaks in cross-interpreter channel operations and shared
+namespace handling.
index 4bfefd65f174466d4e526fdf26222a675fcdd807..2b429a252a8ec240a880892ad61a0d02aa9f50a0 100644 (file)
@@ -562,7 +562,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;
     }
 
index 5818066eebe49aa07f9476c27dfdd7f7a6d46111..d84b53d9021a53f6854c72ba68adad3928c3f0c7 100644 (file)
@@ -435,7 +435,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;
 }
 
index 8382d8b95e071cc8156650ce5869b1bcbb31c78a..2f6324d300dee0176c75c38b16a5a2b3d2274e8e 100644 (file)
@@ -455,8 +455,8 @@ _release_xid_data(_PyCrossInterpreterData *data, int rawfree)
 {
     PyObject *exc = PyErr_GetRaisedException();
     int res = rawfree
-        ? _PyCrossInterpreterData_Release(data)
-        : _PyCrossInterpreterData_ReleaseAndRawFree(data);
+        ? _PyCrossInterpreterData_ReleaseAndRawFree(data)
+        : _PyCrossInterpreterData_Release(data);
     if (res < 0) {
         /* The owning interpreter is already destroyed. */
         _PyCrossInterpreterData_Clear(NULL, data);