Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-140551: Fix dict crash if clear is called at lookup stage#140558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-140551: Fix dict crash if clear is called at lookup stage #140558
Uh oh!
There was an error while loading. Please reload this page.
Conversation
efimov-mikhail commented Oct 24, 2025 • edited by bedevere-app bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-app bot
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.
Misc/NEWS.d/next/Core_and_Builtins/2025-10-24-20-42-33.gh-issue-140551.-9swrl.rst Outdated Show resolvedHide resolved
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 |
efimov-mikhail commented Oct 24, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Yes, it's expected that |
sergey-miryanov left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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. |
02202c1 into python:mainUh 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