]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-132643: use atomic load for dict in specializer (#132653)
authorKumar Aditya <kumaraditya@python.org>
Fri, 18 Apr 2025 09:36:27 +0000 (15:06 +0530)
committerGitHub <noreply@github.com>
Fri, 18 Apr 2025 09:36:27 +0000 (15:06 +0530)
Python/specialize.c

index ceb396c5b548155e1f46b1f75240c235e41622da..48cdcbd2a24cab251b2eeee178611cc4f21ef8fb 100644 (file)
@@ -1641,7 +1641,8 @@ specialize_attr_loadclassattr(PyObject *owner, _Py_CODEUNIT *instr,
             specialize(instr, is_method ? LOAD_ATTR_METHOD_NO_DICT : LOAD_ATTR_NONDESCRIPTOR_NO_DICT);
         }
         else if (is_method) {
-            PyObject *dict = *(PyObject **) ((char *)owner + dictoffset);
+            PyObject **addr = (PyObject **)((char *)owner + dictoffset);
+            PyObject *dict = FT_ATOMIC_LOAD_PTR_ACQUIRE(*addr);
             if (dict) {
                 SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_NOT_MANAGED_DICT);
                 return 0;