Skip to content

Commit b9a1208

Browse files
Fix merge conflicts
1 parent da778df commit b9a1208

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Objects/typeobject.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5781,7 +5781,7 @@ _PyType_LookupStackRefAndVersion(PyTypeObject *type, PyObject *name, _PyStackRef
57815781
// synchronize-with other writing threads by doing an acquire load on the sequence
57825782
while (1) {
57835783
uint32_t sequence = _PySeqLock_BeginRead(&entry->sequence);
5784-
uint32_t entry_version = _Py_atomic_load_uint32_relaxed(&entry->version);
5784+
uint32_t entry_version = _Py_atomic_load_uint32_acquire(&entry->version);
57855785
uint32_t type_version = _Py_atomic_load_uint32_acquire(&type->tp_version_tag);
57865786
if (entry_version == type_version &&
57875787
_Py_atomic_load_ptr_relaxed(&entry->name) == name) {
@@ -5828,11 +5828,14 @@ _PyType_LookupStackRefAndVersion(PyTypeObject *type, PyObject *name, _PyStackRef
58285828
int has_version = 0;
58295829
unsigned int assigned_version = 0;
58305830
BEGIN_TYPE_LOCK();
5831-
res = find_name_in_mro(type, name, &error);
5831+
// We must assign the version before doing the lookup. If
5832+
// find_name_in_mro() blocks and releases the critical section
5833+
// then the type version can change.
58325834
if (MCACHE_CACHEABLE_NAME(name)) {
58335835
has_version = assign_version_tag(interp, type);
58345836
assigned_version = type->tp_version_tag;
58355837
}
5838+
res = find_name_in_mro(type, name, &error);
58365839
END_TYPE_LOCK();
58375840

58385841
/* Only put NULL results into cache if there was no error. */

0 commit comments

Comments
 (0)