GH-101696: invalidate type version tag in `_PyStaticType_Dealloc` (#101697)

This commit is contained in:
Kumar Aditya 2023-02-08 23:32:15 +05:30 committed by GitHub
parent 2a8bf25804
commit d9de079248
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

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

View 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);