Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-109786: Fix leaks when re-enter itertools.pairwise.__next__()#109788
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-109786: Fix leaks when re-enter itertools.pairwise.__next__()#109788
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Modules/itertoolsmodule.c Outdated
| } | ||
| } | ||
| else { | ||
| Py_INCREF(old); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Other simple solution is settingpo->old = NULL instead of increfingold, soold holds the only reference. It only differs from the present solution in casecheck(3, ...), and I tested much more test cases than present in this PR, including multiple re-entering points.
Uh oh!
There was an error while loading.Please reload this page.
rhettinger commentedSep 23, 2023
How does the "borrowed reference" arise? My understanding that an |
serhiy-storchaka commentedSep 23, 2023
|
serhiy-storchaka commentedSep 24, 2023
Now the current result is preserved in all test cases. I also found and fixed a crash due to |
serhiy-storchaka commentedNov 27, 2023
@rhettinger, I am going to merge this if you have no questions or objections. There are many ways to fix leaks, and I tested many variants. The proposed one is the only variant that produces the same result in all tested weird cases (but without leaking of course). |
Thanks@serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
GH-112699 is a backport of this pull request to the3.12 branch. |
….__next__() (pythonGH-109788)(cherry picked from commit6ca9d3e)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
GH-112700 is a backport of this pull request to the3.11 branch. |
….__next__() (pythonGH-109788)(cherry picked from commit6ca9d3e)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.