From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:39:39 +0000 (+0100) Subject: [3.13] gh-128759: fix data race in `type_modified_unlocked` (GH-128764) (#128769) X-Git-Tag: v3.13.2~111 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=632745ade18f5baa39e41613f86114d95c5dce73;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-128759: fix data race in `type_modified_unlocked` (GH-128764) (#128769) * gh-128759: fix data race in `type_modified_unlocked` (GH-128764) (cherry picked from commit 6e1e78054060ad326f26dd8dbf12adfedbb52883) Co-authored-by: sobolevn --- diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 093ebac9b501..bd79676b8e92 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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);