8000 gh-128100: Atomic dict load in _PyObject_GenericGetAttrWithDict by wrongnull · Pull Request #128297 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address the review
  • Loading branch information
wrongnull committed Dec 27, 2024
commit 7227e3ed103e10f13251f60a1c75ec69def704e9
10 changes: 4 additions & 6 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,16 +1715,14 @@ _PyObject_GenericGetAttrWithDict(PyObject *obj, PyObject *name,
dict = (PyObject *)_PyObject_GetManagedDict(obj);
}
else {
Py_BEGIN_CRITICAL_SECTION(obj);
#ifdef DISABLE_GIL
PyObject **dictptr = _Py_atomic_load_ptr(_PyObject_ComputedDictPointer(obj));
#else
PyObject **dictptr = _PyObject_ComputedDictPointer(obj);
#endif
if (dictptr) {
#ifdef Py_GIL_DISABLED
dict = _Py_atomic_load_ptr_acquire(dictptr);
#else
dict = *dictptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is where the atomic load should be. (And, as Sam said in the issue, we want _Py_atomic_load_ptr_acquire instead of plain old _Py_atomic_load_ptr.)

#endif
}
Py_END_CRITICAL_SECTION();
}
}
if (dict != NULL) {
Expand Down
Loading
0