]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-101696: invalidate type version tag in `_PyStaticType_Dealloc` (#101697)
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Wed, 8 Feb 2023 18:02:15 +0000 (23:32 +0530)
committerGitHub <noreply@github.com>
Wed, 8 Feb 2023 18:02:15 +0000 (23:32 +0530)
Misc/NEWS.d/next/Core and Builtins/2023-02-08-17-13-31.gh-issue-101696.seJhTt.rst [new file with mode: 0644]
Objects/typeobject.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-02-08-17-13-31.gh-issue-101696.seJhTt.rst b/Misc/NEWS.d/next/Core and Builtins/2023-02-08-17-13-31.gh-issue-101696.seJhTt.rst
new file mode 100644 (file)
index 0000000..ff2bbb4
--- /dev/null
@@ -0,0 +1 @@
+Invalidate type version tag in ``_PyStaticType_Dealloc`` for static types, avoiding bug where a false cache hit could crash the interpreter. Patch by Kumar Aditya.
index 59e0bf2995bac22beb7d8f6f2bb782d7cf853157..bf6ccdb77a90f016e177ea500b48c1d85a250cfa 100644 (file)
@@ -4469,6 +4469,8 @@ _PyStaticType_Dealloc(PyTypeObject *type)
     }
 
     type->tp_flags &= ~Py_TPFLAGS_READY;
+    type->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
+    type->tp_version_tag = 0;
 
     if (type->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) {
         _PyStaticType_ClearWeakRefs(type);