]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-94893: Ignore caches when adding LOAD_FAST_CHECKs (GH-94894)
authorBrandt Bucher <brandtbucher@microsoft.com>
Mon, 18 Jul 2022 16:00:41 +0000 (09:00 -0700)
committerGitHub <noreply@github.com>
Mon, 18 Jul 2022 16:00:41 +0000 (09:00 -0700)
Misc/NEWS.d/next/Core and Builtins/2022-07-15-22-47-44.gh-issue-94893.YiJYcW.rst [new file with mode: 0644]
Objects/frameobject.c

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 (file)
index 0000000..6384ef9
--- /dev/null
@@ -0,0 +1,2 @@
+Fix an issue where frame object manipulations could corrupt inline bytecode
+caches.
index 3e97b75d4bf5ac0cd7b97fc56fed3f6e15099024..fe8eaa341fb334a2b51df3fefbd7fd97ecbe9b57 100644 (file)
@@ -603,7 +603,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:
@@ -619,6 +620,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