-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-145678: Fix use-after-free in itertools.groupby _grouper_next() #145679
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
Closed
+29
−1
Closed
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
79bcea0
gh-145678: Fix use-after-free in itertools.groupby _grouper_next()
sampsonc 29df8e8
gh-145678: Simplify test_grouper_next_reentrant_eq_does_not_crash
sampsonc 867c8ee
gh-145678: Remove unnecessary try/except in test
sampsonc cb4cc82
Update Modules/itertoolsmodule.c
sampsonc fbf0a25
Update Lib/test/test_itertools.py
sampsonc 39dd69c
Update Misc/NEWS.d/next/Library/2026-03-09-00-00-00.gh-issue-145678.g…
sampsonc 1fa0e35
Merge branch 'main' into gh-145678-grouper-uaf
sampsonc 1863876
gh-145678: Update NEWS entry wording per review
sampsonc 5daf7c4
Merge branch 'main' into gh-145678-grouper-uaf
sampsonc 750b54a
gh-145678: Strengthen test to assert refcount invariant
sampsonc d9f4834
gh-145678: Guard against re-entrant __eq__ never being called
sampsonc fb85cf1
gh-145678: Revert sys.getrefcount assertions from test
sampsonc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
Misc/NEWS.d/next/Library/2026-03-09-00-00-00.gh-issue-145678.grouper-uaf.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Fix a use-after-free in :func:`itertools.groupby`: the internal | ||
| ``_grouper_next()`` function did not hold strong references to | ||
| ``gbo->currkey`` and ``igo->tgtkey`` before calling | ||
| :c:func:`PyObject_RichCompareBool`, so a re-entrant ``__eq__`` that advanced | ||
| the parent iterator (triggering ``groupby_step()`` and ``Py_XSETREF`` on | ||
| ``currkey``) could free those objects while they were still being compared. | ||
| The fix mirrors the protection added in :gh:`143543` for ``groupby_next()``. | ||
|
sampsonc marked this conversation as resolved.
Outdated
sampsonc marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.