Repository navigation
gh-158032: Keep the element tag alive during Element.iter comparison - #158044
Conversation
|
The fix is correct, and matches what The test can be simpler: iterating and checking the result is enough, without |
|
@serhiy-storchaka. Done. I've simplified the test and mentioned the crash in the NEWS entry. |
|
Sorry, my suggestion was wrong: please restore the previous test. On a debug build it crashes with SIGSEGV without the fix and passes with it, while the simplified test passes either way: nothing in it looks at the freed tag, so only ASan sees the use-after-free. The |
|
@serhiy-storchaka. Ok! Restored. |
|
LGTM. 👍 |
|
Thanks @lul-cas for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Thanks @lul-cas for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
|
GH-161913 is a backport of this pull request to the 3.14 branch. |
|
GH-161914 is a backport of this pull request to the 3.15 branch. |
Element.iter compared each element's tag through a borrowed reference. A reentrant eq can replace that tag and free it while the comparison is still using it.
Hold a strong reference for the duration of PyObject_RichCompareBool, as Element.find already does.
Fixes #158032.