From 4c3d187d9f143eee930a88a38b90f4842911b8be Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Fri, 18 Apr 2025 21:43:49 +0530 Subject: [PATCH] gh-126366: fix thread safety of dict key iterator (#132693) --- Objects/dictobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 792a34cc569f..ff6dbb8bed30 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -5495,7 +5495,7 @@ dictiter_iternext_threadsafe(PyDictObject *d, PyObject *self, ensure_shared_on_read(d); i = _Py_atomic_load_ssize_relaxed(&di->di_pos); - k = _Py_atomic_load_ptr_relaxed(&d->ma_keys); + k = _Py_atomic_load_ptr_acquire(&d->ma_keys); assert(i >= 0); if (_PyDict_HasSplitTable(d)) { PyDictValues *values = _Py_atomic_load_ptr_relaxed(&d->ma_values); -- 2.47.3