From 2374547f1f04b7f5219b19f2d1c56d5cd8c4ef27 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 15 Jul 2022 22:43:05 -0700 Subject: [PATCH 1/2] Ignore caches when adding LOAD_FAST_CHECKs --- Objects/frameobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 6f4de65cc7c0d0f..11ff8f1e009b170 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -493,7 +493,8 @@ add_load_fast_null_checks(PyCodeObject *co) int changed = 0; _Py_CODEUNIT *instructions = _PyCode_CODE(co); for (Py_ssize_t i = 0; i < Py_SIZE(co); i++) { - switch (_Py_OPCODE(instructions[i])) { + int opcode = _Py_OPCODE(instructions[i]); + switch (opcode) { case LOAD_FAST: case LOAD_FAST__LOAD_FAST: case LOAD_FAST__LOAD_CONST: @@ -509,6 +510,7 @@ add_load_fast_null_checks(PyCodeObject *co) _Py_SET_OPCODE(instructions[i], STORE_FAST); break; } + i += _PyOpcode_Caches[_PyOpcode_Deopt[opcode]]; } if (changed) { // invalidate cached co_code object From b66628377785c764155067a7b6c458d5edbdc5f3 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 15 Jul 2022 22:47:53 -0700 Subject: [PATCH 2/2] blurb add --- .../2022-07-15-22-47-44.gh-issue-94893.YiJYcW.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-07-15-22-47-44.gh-issue-94893.YiJYcW.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-07-15-22-47-44.gh-issue-94893.YiJYcW.rst b/Misc/NEWS.d/next/Core and Builtins/2022-07-15-22-47-44.gh-issue-94893.YiJYcW.rst new file mode 100644 index 000000000000000..6384ef92c6543a3 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-07-15-22-47-44.gh-issue-94893.YiJYcW.rst @@ -0,0 +1,2 @@ +Fix an issue where frame object manipulations could corrupt inline bytecode +caches.