Uh oh!
There was an error while loading. Please reload this page.
gh-140551: Fix dict crash if clear is called at lookup stage - #140558
gh-140551: Fix dict crash if clear is called at lookup stage#140558kumaraditya303 merged 11 commits into
dict crash if clear is called at lookup stage#140558Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
sergey-miryanov
commented
Oct 24, 2025
For the following repro: It crashes inside |
sergey-miryanov
commented
Oct 24, 2025
For the following repro: It crashes also inside Both repro tests on Windows 11 on main branch. |
…e-140551.-9swrl.rst Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
sergey-miryanov
commented
Oct 24, 2025
Another one I found on main: It is aborted with |
Yes, it's expected that |
methane
commented
Oct 26, 2025
I'm not sure if this is the correct solution. If the keys of a dictionary change during a dict lookup, can we trust the result of the lookup (e.g. Shouldn't it raise an error if the keys of a dict change during a lookup? |
vstinner
commented
Oct 26, 2025
I like this error: PyErr_SetString(PyExc_RuntimeError,
"dict mutated during update"); |
colesbury
commented
Oct 26, 2025
CPython behavior has been to retry the lookup if the key changes (since Python 2.2, 453163d). I don't think we should change it. |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
efimov-mikhail
commented
Oct 29, 2025
IIUC, problem is fixed and CI is green. |
Uh oh!
There was an error while loading. Please reload this page.
Thanks @efimov-mikhail for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
Sorry, @efimov-mikhail and @kumaraditya303, I could not cleanly backport this to |
Sorry, @efimov-mikhail and @kumaraditya303, I could not cleanly backport this to |
efimov-mikhail
commented
Oct 29, 2025
Thanks for the merge, @kumaraditya303. |
…age (python#140558) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
GH-140743 is a backport of this pull request to the 3.14 branch. |
…age (python#140558) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
GH-140744 is a backport of this pull request to the 3.13 branch. |
efimov-mikhail
commented
Oct 30, 2025
FYI, @kumaraditya303 |
This fixes a regression introduced in pythongh-140558. The interpreter would crash if we inserted a non `str` key into a split table that matches an existing key.
This fixes a regression introduced in pythongh-140558. The interpreter would crash if we inserted a non `str` key into a split table that matches an existing key. (cherry picked from commit 547d8da) Co-authored-by: Sam Gross <colesbury@gmail.com>
…2229) This fixes a regression introduced in pythongh-140558. The interpreter would crash if we inserted a non `str` key into a split table that matches an existing key. (cherry picked from commit 547d8da) Co-authored-by: Sam Gross <colesbury@gmail.com>
…age (python#140558) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
This fixes a regression introduced in pythongh-140558. The interpreter would crash if we inserted a non `str` key into a split table that matches an existing key.
dictifhash__eq__function has side effects #140551