gh-143635: Fix crash in _Py_typing_type_repr#143670
Conversation
|
This needs NEWS since it fixes a user-visible crash. |
JelleZijlstra
left a comment
There was a problem hiding this comment.
Actually this is incorrect. The crash can be triggered if the list is cleared while we're iterating over it in ga_repr_items_list. INCREFing here is insufficient to protect us because the item may not be valid in the first place any more by the time we receive it.
My repro case in #143823 makes this clearer.
|
When you're done making the requested changes, leave the comment: |
|
Thank you! I refactored the PR to include the fix for the third case. |
a811a1d to
4e08352
Compare
|
I thought there were more occurrences pf this function but am I wrong? or is it just me on mobile? |
|
Or is it just in recursive calls where we already hold enough strong references? |
|
The other calls look safe to me. |
|
Thanks @sobolevn for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
(cherry picked from commit bdba5f0) Co-authored-by: sobolevn <mail@sobolevn.me>
|
Sorry, @sobolevn, I could not cleanly backport this to |
|
GH-143851 is a backport of this pull request to the 3.14 branch. |
|
GH-143852 is a backport of this pull request to the 3.13 branch. |
) (cherry picked from commit bdba5f0)
|
I also added one more test case for a second possible crash in the same function.
_Py_typing_type_reprvia re-entrant__origin__lookup duringGenericAliasrepr #143635