https://github.com/python/cpython/commit/542b4f47a8d2df4b60bbf0c0c90d5fb00d53c59e commit: 542b4f47a8d2df4b60bbf0c0c90d5fb00d53c59e branch: 3.14 author: sobolevn <[email protected]> committer: sobolevn <[email protected]> date: 2026-11-15T16:48:15Z summary:
[3.14] gh-152254: Fix a crash in `PyObject_ClearManagedDict` under memory pressure (GH-152255) (#162042) (cherry picked from commit 369d8bc4f6fe1f751de2512523a1acb95491a5eb) Co-authored-by: Victor Stinner <[email protected]> files: A Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-11-34-50.gh-issue-152254.yK6TGp.rst M Objects/dictobject.c diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-11-34-50.gh-issue-152254.yK6TGp.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-11-34-50.gh-issue-152254.yK6TGp.rst new file mode 100644 index 000000000000000..206b88a2affb2b2 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-11-34-50.gh-issue-152254.yK6TGp.rst @@ -0,0 +1,2 @@ +Fix a crash during the clean up of managed dict objects under a memory +pressure in :c:func:`PyObject_ClearManagedDict`. diff --git a/Objects/dictobject.c b/Objects/dictobject.c index e857596c0837b12..45d0a4e3d24517a 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -7530,6 +7530,7 @@ PyObject_ClearManagedDict(PyObject *obj) Py_BEGIN_CRITICAL_SECTION(dict); PyInterpreterState *interp = _PyInterpreterState_GET(); PyDictKeysObject *oldkeys = dict->ma_keys; + ensure_shared_on_resize(dict); set_keys(dict, Py_EMPTY_KEYS); dict->ma_values = NULL; dictkeys_decref(interp, oldkeys, IS_DICT_SHARED(dict)); _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
