From 5f4e2e81db1d3425af541a21b86186d35fa4fb60 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 10 Jun 2026 15:02:42 +0300 Subject: [PATCH 1/3] gh-151126: Fix missing memory errors in `_interpchannelsmodule.c` --- .../2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst | 1 + Modules/_interpchannelsmodule.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst index 81e87e539865ce3..b43297420a54d15 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst @@ -3,5 +3,6 @@ which happened in: - code compilation - :func:`!_winapi.CreateProcess` +- :mod:`!_interpchannels` module Now these places raise proper :exc:`MemoryError` errors. diff --git a/Modules/_interpchannelsmodule.c b/Modules/_interpchannelsmodule.c index c6d107d243dda0e..3614890757d69da 100644 --- a/Modules/_interpchannelsmodule.c +++ b/Modules/_interpchannelsmodule.c @@ -921,7 +921,8 @@ static _channelends * _channelends_new(void) { _channelends *ends = GLOBAL_MALLOC(_channelends); - if (ends== NULL) { + if (ends == NULL) { + PyErr_NoMemory(); return NULL; } ends->numsendopen = 0; @@ -1115,6 +1116,7 @@ _channel_new(PyThread_type_lock mutex, struct _channeldefaults defaults) assert(check_unbound(defaults.unboundop)); _channel_state *chan = GLOBAL_MALLOC(_channel_state); if (chan == NULL) { + PyErr_NoMemory(); return NULL; } chan->mutex = mutex; @@ -1313,6 +1315,7 @@ _channelref_new(int64_t cid, _channel_state *chan) { _channelref *ref = GLOBAL_MALLOC(_channelref); if (ref == NULL) { + PyErr_NoMemory(); return NULL; } ref->cid = cid; @@ -1698,6 +1701,7 @@ _channel_set_closing(_channelref *ref, PyThread_type_lock mutex) { } chan->closing = GLOBAL_MALLOC(struct _channel_closing); if (chan->closing == NULL) { + PyErr_NoMemory(); goto done; } chan->closing->ref = ref; From 9d524335142eb19503adfe02603bbb312d0d484e Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 10 Jun 2026 15:12:12 +0300 Subject: [PATCH 2/3] Fix docs --- .../2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst index b43297420a54d15..270fbf4b14f42fd 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst @@ -1,8 +1,7 @@ -Fix a crash, when there's no memory left on a device, -which happened in: +Fix a crash, when there's no memory left on a device, which happened in: - code compilation -- :func:`!_winapi.CreateProcess` - :mod:`!_interpchannels` module +- :func:`!_winapi.CreateProcess` function Now these places raise proper :exc:`MemoryError` errors. From 96c750a2c56c662147f9594a8d90ade7dc739c11 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 10 Jun 2026 15:19:36 +0300 Subject: [PATCH 3/3] Fix docs --- .../2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst index 270fbf4b14f42fd..67e2ce4044431f9 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst @@ -1,7 +1,5 @@ -Fix a crash, when there's no memory left on a device, which happened in: - -- code compilation -- :mod:`!_interpchannels` module -- :func:`!_winapi.CreateProcess` function +Fix a crash, when there's no memory left on a device, +which happened in: code compilation, :mod:`!_interpchannels` module, +:func:`!_winapi.CreateProcess` function. Now these places raise proper :exc:`MemoryError` errors.