]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-117657: Fix data race in `dict_dict_merge` (gh-129755) (gh-129808)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 7 Feb 2025 15:18:57 +0000 (16:18 +0100)
committerGitHub <noreply@github.com>
Fri, 7 Feb 2025 15:18:57 +0000 (10:18 -0500)
Found while running `test_load_attr_module` from `test_opcache` under TSan.
(cherry picked from commit 34379d0a593e5a76e2f754cdd7fccb79f25a4613)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Objects/dictobject.c

index ff16a41b9a5d4e2127d0ab4d49a185ba916f6222..f947b44b039eb47c535ef7c50b92de5cfc8f9437 100644 (file)
@@ -3713,7 +3713,7 @@ dict_dict_merge(PyInterpreterState *interp, PyDictObject *mp, PyDictObject *othe
 
             ensure_shared_on_resize(mp);
             dictkeys_decref(interp, mp->ma_keys, IS_DICT_SHARED(mp));
-            mp->ma_keys = keys;
+            set_keys(mp, keys);
             STORE_USED(mp, other->ma_used);
             mp->ma_version_tag = new_version;
             ASSERT_CONSISTENT(mp);