]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-128759: fix data race in `type_modified_unlocked` (GH-128764) (#128769)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 13 Jan 2025 12:39:39 +0000 (13:39 +0100)
committerGitHub <noreply@github.com>
Mon, 13 Jan 2025 12:39:39 +0000 (18:09 +0530)
* gh-128759: fix data race in `type_modified_unlocked` (GH-128764)
(cherry picked from commit 6e1e78054060ad326f26dd8dbf12adfedbb52883)

Co-authored-by: sobolevn <mail@sobolevn.me>
Objects/typeobject.c

index 093ebac9b50179624f6c8649d49d5bb4e3b89e30..bd79676b8e925fbbe58dcaa528f7fc93b71f8eee 100644 (file)
@@ -996,9 +996,15 @@ type_modified_unlocked(PyTypeObject *type)
        We don't assign new version tags eagerly, but only as
        needed.
      */
+#ifdef Py_GIL_DISABLED
+    if (_Py_atomic_load_uint_relaxed(&type->tp_version_tag) == 0) {
+        return;
+    }
+#else
     if (type->tp_version_tag == 0) {
         return;
     }
+#endif
     // Cannot modify static builtin types.
     assert((type->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) == 0);