Uh oh!
There was an error while loading. Please reload this page.
gh-151633: avoid use-after-free in Counter.update - #151634
gh-151633: avoid use-after-free in Counter.update#151634KowalskiThomas wants to merge 9 commits into
Counter.update#151634Conversation
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
KowalskiThomas
commented
Jul 9, 2026
Thanks for the review, I'll take a look ASAP. |
| int found; | ||
| int cs_err = 0; | ||
| PyObject *newval = NULL; | ||
| Py_BEGIN_CRITICAL_SECTION(mapping); |
There was a problem hiding this comment.
The current PR looks good, but I think we can improve a bit more. The locking via the critical section now happens on each iteration, which seems a bit of a waste.
Can we place the critical section outside the while loop and then extract most (all?) of the code into a method _count_elements_dict_lock_held?
There was a problem hiding this comment.
I'll look into this as soon as possible, thanks for reporting.
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
192fc9f to
c34c4a2CompareKowalskiThomas
commented
Jul 14, 2026
Sorry in advance, I had to rebase on main (instead of merge) because Git wouldn't let me "merge unrelated histories"... Not sure what happened there... |
Fixes#151633.
Counter.updatecan cause a use after free #151633