-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-141805: avoid increase the set->used twice when the __eq__ trigger another add #142007
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
Changes from all commits
cfdeb5c
4a2440d
08f7e68
cf1400f
13ccc5b
de4dbb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
kemingy marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix set corruption due to invalid length calculation when set additions occur | ||
| in the element comparison (:meth:`object.__eq__`) methods. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -298,6 +298,7 @@ set_add_entry_takeref(PySetObject *so, PyObject *key, Py_hash_t hash) | |
| else if (entry->hash == -1) { | ||
| assert (entry->key == dummy); | ||
| freeslot = entry; | ||
| goto found_unused_or_dummy; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this is incorrect. Imagine you added two elements with the same hash, A and B. Then A hes been removed, and replaced with a dummy (this is why dummy is needed). Then we try to add B again. With your code, it will find a dummy in place of A, and replace it with B. Now you have two Bs in a set.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #143781 adds a test for this. |
||
| } | ||
| entry++; | ||
| } while (probes--); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.