Repository navigation
gh-158197: Fix split dict iteration during concurrent deletion - #158686
Conversation
Read insertion order from the iterator's captured values snapshot instead of re-reading ma_values and asserting against a concurrently changing size. Retry under the dictionary lock when a value slot has been cleared. Make insertion-order writes atomic and publish size changes with release stores, pairing with the iterator's size load. Keep order-byte accesses relaxed. Add _Py_atomic_store_uint8_release() and FT_ATOMIC_STORE_UINT8_RELEASE() for this.
|
The CI failure on Windows should be fixed by GH-158977, I think. |
|
@DinoV mentioned we might investigate the performance impact of this. Split dicts are used for instance attributes. Therefore, we don't want to make the insert/update operation slower, if we can help it. That slowdown would be caused by using a release order store for I also tried re-working the PR to use a relaxed store on |
|
Thanks @nascheme for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
GH-159953 is a backport of this pull request to the 3.15 branch. |
|
Sorry, @nascheme, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
Fix crashes and debug-build assertion failures in the free-threaded build when iterating over a split dictionary while another thread deletes entries or clears it. Publish insertion-order updates atomically so readers cannot observe an increased size before the corresponding order entry is initialized.
This is based on the patch attached to GH-158197 with some refinement. Note that AI agents (Claude and GPT) assisted in making and testing change.