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. 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(