From 7646b10a629e3d10eafdd297e275a24409379b7e Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Tue, 13 Jan 2026 19:30:06 +0000 Subject: [PATCH 1/3] Limit executor growth --- Python/optimizer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Python/optimizer.c b/Python/optimizer.c index 79ac179d0b710a..8469966e379b98 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -72,6 +72,9 @@ get_index_for_executor(PyCodeObject *code, _Py_CODEUNIT *instr) } assert(size <= capacity); if (size == capacity) { + if (capacity * 2 >= MAX_EXECUTORS_SIZE) { + return -1; + } /* Array is full. Grow array */ int new_capacity = capacity ? capacity * 2 : 4; _PyExecutorArray *new = PyMem_Realloc( From ed05c8ebbd444a0943737a86c175ffcdfe8ed9a1 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 13 Jan 2026 19:32:02 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2026-01-13-19-31-56.gh-issue-143807.H5KP1C.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-01-13-19-31-56.gh-issue-143807.H5KP1C.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-13-19-31-56.gh-issue-143807.H5KP1C.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-13-19-31-56.gh-issue-143807.H5KP1C.rst new file mode 100644 index 00000000000000..eb1a74ce784e7e --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-13-19-31-56.gh-issue-143807.H5KP1C.rst @@ -0,0 +1 @@ +Place a limit on the number of JIT executors. From a88e8814192e7d814243e7d261369350080a7d2a Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Mon, 16 Mar 2026 23:16:37 +0800 Subject: [PATCH 3/3] Apply code review --- Python/optimizer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/optimizer.c b/Python/optimizer.c index 8469966e379b98..eccd17f0831e3d 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -72,11 +72,11 @@ get_index_for_executor(PyCodeObject *code, _Py_CODEUNIT *instr) } assert(size <= capacity); if (size == capacity) { - if (capacity * 2 >= MAX_EXECUTORS_SIZE) { - return -1; - } /* Array is full. Grow array */ int new_capacity = capacity ? capacity * 2 : 4; + if (new_capacity >= MAX_EXECUTORS_SIZE) { + return -1; + } _PyExecutorArray *new = PyMem_Realloc( old, offsetof(_PyExecutorArray, executors) +