Skip to content
Merged
Show file tree
Hide file tree
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
Lock in dictresize, not in callers
  • Loading branch information
DinoV committed Feb 20, 2024
commit 7407ce9820a900550bf12655825dc30d2784c823
4 changes: 2 additions & 2 deletions Include/cpython/pyatomic_msc.h
Original file line number Diff line number Diff line change
Expand Up @@ -945,9 +945,9 @@ _Py_atomic_store_ssize_release(Py_ssize_t *obj, Py_ssize_t value)
#if defined(_M_X64) || defined(_M_IX86)
*(Py_ssize_t volatile *)obj = value;
#elif defined(_M_ARM64)
__stlr64((unsigned __int64 volatile *)obj, (uintptr_t)value);
__stlr64((unsigned __int64 volatile *)obj, (unsigned __int64)value);
#else
# error "no implementation of _Py_atomic_store_int_release"
# error "no implementation of _Py_atomic_store_ssize_release"
#endif
}

Expand Down
12 changes: 3 additions & 9 deletions Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,6 @@ insert_split_dict(PyInterpreterState *interp, PyDictObject *mp,
return -1;
}
assert(!_PyDict_HasSplitTable(mp));
assert(DK_IS_UNICODE(keys));
return insert_combined_dict(interp, mp, hash, key, value);
}

Expand Down Expand Up @@ -1609,7 +1608,7 @@ dictresize(PyInterpreterState *interp, PyDictObject *mp,
Py_ssize_t numentries = mp->ma_used;

if (oldvalues != NULL) {
ASSERT_KEYS_LOCKED(oldkeys);
LOCK_KEYS(oldkeys);
PyDictUnicodeEntry *oldentries = DK_UNICODE_ENTRIES(oldkeys);
/* Convert split table into new combined table.
* We must incref keys; we can transfer values.
Expand Down Expand Up @@ -1640,6 +1639,7 @@ dictresize(PyInterpreterState *interp, PyDictObject *mp,
}
build_indices_unicode(mp->ma_keys, newentries, numentries);
}
UNLOCK_KEYS(oldkeys);
dictkeys_decref(interp, oldkeys);
mp->ma_values = NULL;
free_values(oldvalues);
Expand Down Expand Up @@ -3998,14 +3998,8 @@ dict_popitem_impl(PyDictObject *self)
/* Convert split table to combined table */
if (_PyDict_HasSplitTable(self)) {
PyDictKeysObject *keys = self->ma_keys;
dictkeys_incref(keys);
LOCK_KEYS(keys);

int status = dictresize(interp, self, DK_LOG_SIZE(self->ma_keys), 1);
UNLOCK_KEYS(keys);
dictkeys_decref(interp, keys);

if (status < 0) {
if (dictresize(interp, self, DK_LOG_SIZE(self->ma_keys), 1) < 0) {
Py_DECREF(res);
return NULL;
}
Expand Down