From 9b2987915347d2bc56202f58400faf7f7c9315e0 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 25 Jun 2026 10:08:36 +0300 Subject: [PATCH] gh-152156: Fix a crash in `interpeters.create` under limited memory conditions --- .../Library/2026-06-25-10-07-54.gh-issue-152156.gscPU9.rst | 2 ++ Modules/_interpchannelsmodule.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2026-06-25-10-07-54.gh-issue-152156.gscPU9.rst diff --git a/Misc/NEWS.d/next/Library/2026-06-25-10-07-54.gh-issue-152156.gscPU9.rst b/Misc/NEWS.d/next/Library/2026-06-25-10-07-54.gh-issue-152156.gscPU9.rst new file mode 100644 index 000000000000000..30e561274dc50c2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-06-25-10-07-54.gh-issue-152156.gscPU9.rst @@ -0,0 +1,2 @@ +Fix a possible crash in :func:`concurrent.interpreters.create` under limited +memory conditions. diff --git a/Modules/_interpchannelsmodule.c b/Modules/_interpchannelsmodule.c index 3614890757d69da..05957081079d4a0 100644 --- a/Modules/_interpchannelsmodule.c +++ b/Modules/_interpchannelsmodule.c @@ -2951,10 +2951,8 @@ channelsmod_create(PyObject *self, PyObject *args, PyObject *kwds) &cidobj); if (handle_channel_error(err, self, cid)) { assert(cidobj == NULL); - err = channel_destroy(&_globals.channels, cid); - if (handle_channel_error(err, self, cid)) { - // XXX issue a warning? - } + assert(PyErr_Occurred()); + (void)channel_destroy(&_globals.channels, cid); return NULL; } assert(cidobj != NULL);