Skip to content

Commit 632745a

Browse files
[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 6e1e780) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent afcf238 commit 632745a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Objects/typeobject.c

+6
Original file line numberDiff line numberDiff line change
@@ -996,9 +996,15 @@ type_modified_unlocked(PyTypeObject *type)
996996
We don't assign new version tags eagerly, but only as
997997
needed.
998998
*/
999+
#ifdef Py_GIL_DISABLED
1000+
if (_Py_atomic_load_uint_relaxed(&type->tp_version_tag) == 0) {
1001+
return;
1002+
}
1003+
#else
9991004
if (type->tp_version_tag == 0) {
10001005
return;
10011006
}
1007+
#endif
10021008
// Cannot modify static builtin types.
10031009
assert((type->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) == 0);
10041010

0 commit comments

Comments
 (0)