Skip to content

Commit 4914ba8

Browse files
committed
Lock in dictresize, not in callers
1 parent 1eeb3d0 commit 4914ba8

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

Include/cpython/pyatomic_msc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,9 +945,9 @@ _Py_atomic_store_ssize_release(Py_ssize_t *obj, Py_ssize_t value)
945945
#if defined(_M_X64) || defined(_M_IX86)
946946
*(Py_ssize_t volatile *)obj = value;
947947
#elif defined(_M_ARM64)
948-
__stlr64((unsigned __int64 volatile *)obj, (uintptr_t)value);
948+
__stlr64((unsigned __int64 volatile *)obj, (unsigned __int64)value);
949949
#else
950-
# error "no implementation of _Py_atomic_store_int_release"
950+
# error "no implementation of _Py_atomic_store_ssize_release"
951951
#endif
952952
}
953953

Objects/dictobject.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,6 @@ insert_split_dict(PyInterpreterState *interp, PyDictObject *mp,
13501350
return -1;
13511351
}
13521352
assert(!_PyDict_HasSplitTable(mp));
1353-
assert(DK_IS_UNICODE(keys));
13541353
return insert_combined_dict(interp, mp, hash, key, value);
13551354
}
13561355

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

16111610
if (oldvalues != NULL) {
1612-
ASSERT_KEYS_LOCKED(oldkeys);
1611+
LOCK_KEYS(oldkeys);
16131612
PyDictUnicodeEntry *oldentries = DK_UNICODE_ENTRIES(oldkeys);
16141613
/* Convert split table into new combined table.
16151614
* We must incref keys; we can transfer values.
@@ -1640,6 +1639,7 @@ dictresize(PyInterpreterState *interp, PyDictObject *mp,
16401639
}
16411640
build_indices_unicode(mp->ma_keys, newentries, numentries);
16421641
}
1642+
UNLOCK_KEYS(oldkeys);
16431643
dictkeys_decref(interp, oldkeys);
16441644
mp->ma_values = NULL;
16451645
free_values(oldvalues);
@@ -3998,14 +3998,8 @@ dict_popitem_impl(PyDictObject *self)
39983998
/* Convert split table to combined table */
39993999
if (_PyDict_HasSplitTable(self)) {
40004000
PyDictKeysObject *keys = self->ma_keys;
4001-
dictkeys_incref(keys);
4002-
LOCK_KEYS(keys);
4003-
4004-
int status = dictresize(interp, self, DK_LOG_SIZE(self->ma_keys), 1);
4005-
UNLOCK_KEYS(keys);
4006-
dictkeys_decref(interp, keys);
40074001

4008-
if (status < 0) {
4002+
if (dictresize(interp, self, DK_LOG_SIZE(self->ma_keys), 1) < 0) {
40094003
Py_DECREF(res);
40104004
return NULL;
40114005
}

0 commit comments

Comments
 (0)