René's URL Explorer Experiment


Title: gh-143543: Fix re-entrant use-after-free in itertools.groupby by VanshAgarwal24036 · Pull Request #143738 · python/cpython · GitHub

Open Graph Title: gh-143543: Fix re-entrant use-after-free in itertools.groupby by VanshAgarwal24036 · Pull Request #143738 · python/cpython

X Title: gh-143543: Fix re-entrant use-after-free in itertools.groupby by VanshAgarwal24036 · Pull Request #143738 · python/cpython

Description: Fix a use-after-free in itertools.groupby when a user-defined eq re-enters next(groupby) during key comparison. groupby_next() compared borrowed references to currkey and tgtkey using PyObject_RichCompareBool(). A re-entrant eq could advance the iterator, replace and decref those keys, leaving the outer comparison accessing freed memory. The fix temporarily INCREFs both keys for the duration of the comparison, preventing re-entrancy from invalidating them. A regression test is added. Issue: gh-143543

Open Graph Description: Fix a use-after-free in itertools.groupby when a user-defined eq re-enters next(groupby) during key comparison. groupby_next() compared borrowed references to currkey and tgtkey using PyObject_Rich...

X Description: Fix a use-after-free in itertools.groupby when a user-defined eq re-enters next(groupby) during key comparison. groupby_next() compared borrowed references to currkey and tgtkey using PyObject_Rich...

Opengraph URL: https://github.com/python/cpython/pull/143738

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:d3c218a1-a8b6-5b0d-8d7f-ef27a558d848
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id81E8:3B4D95:3A0D11:52BAC8:6A572B77
html-safe-noncea40387b6815d3fc6459201cda9c95b1b36d0f5a530b60e63005fa1cfd7407dc8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MUU4OjNCNEQ5NTozQTBEMTE6NTJCQUM4OjZBNTcyQjc3IiwidmlzaXRvcl9pZCI6IjE4MzU0MTE0MTE5NTYwODM1NzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac3b7275595377b094c590fb5fe6754df53b5a8735ebd577794b54212d9b83cddf
hovercard-subject-tagpull_request:3166591033
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/143738/files
twitter:imagehttps://avatars.githubusercontent.com/u/148854295?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/148854295?s=400&v=4
og:image:altFix a use-after-free in itertools.groupby when a user-defined eq re-enters next(groupby) during key comparison. groupby_next() compared borrowed references to currkey and tgtkey using PyObject_Rich...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2576d1f0198cf1588faf2edf27f1ed120903be10
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/143738/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F143738%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F143738%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/143738/files
Reloadhttps://github.com/python/cpython/pull/143738/files
Reloadhttps://github.com/python/cpython/pull/143738/files
Please reload this pagehttps://github.com/python/cpython/pull/143738/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/143738/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
encukouhttps://github.com/encukou
python:mainhttps://github.com/python/cpython/tree/main
VanshAgarwal24036:gh-143543-groupby-uafhttps://github.com/VanshAgarwal24036/cpython/tree/gh-143543-groupby-uaf
Conversation 30 https://github.com/python/cpython/pull/143738
Commits 22 https://github.com/python/cpython/pull/143738/commits
Checks 53 https://github.com/python/cpython/pull/143738/checks
Files changed https://github.com/python/cpython/pull/143738/files
Please reload this pagehttps://github.com/python/cpython/pull/143738/files
gh-143543: Fix re-entrant use-after-free in itertools.groupby https://github.com/python/cpython/pull/143738/files#top
Show all changes 22 commits https://github.com/python/cpython/pull/143738/files
e898626 gh-143543: Fix re-entrant use-after-free in itertools.groupby VanshAgarwal24036 Jan 12, 2026 https://github.com/python/cpython/pull/143738/commits/e898626432a811fb000251efc12927cbd7c57836
ba974bc Fix whitespace per prek VanshAgarwal24036 Jan 12, 2026 https://github.com/python/cpython/pull/143738/commits/ba974bca279ae55feadbd099733cb61f82027d1e
0debc2a Add NEWS entry for itertools.groupby crash fix VanshAgarwal24036 Jan 13, 2026 https://github.com/python/cpython/pull/143738/commits/0debc2a0bd1fd2e3a7f7036e9215289733a37e34
8d83176 Fix NEWS filename for gh-143543 VanshAgarwal24036 Jan 13, 2026 https://github.com/python/cpython/pull/143738/commits/8d831767d3ee54448b3c8d0e038a0fc0258a8ff6
ca932bf Fix NEWS entry type for gh-143543 VanshAgarwal24036 Jan 13, 2026 https://github.com/python/cpython/pull/143738/commits/ca932bf3433216f30b038fc47ced40082129d50a
0e86303 Remove incorrect NEWS files for gh-143543 VanshAgarwal24036 Jan 13, 2026 https://github.com/python/cpython/pull/143738/commits/0e86303246ba709a7ecfbd871214899171ef8642
740218c Avoid borrowed references during groupby key comparison VanshAgarwal24036 Jan 13, 2026 https://github.com/python/cpython/pull/143738/commits/740218ccfe96ab468263a0f5c09a8c54628e7e44
e3a54be Clarify NEWS entry wording VanshAgarwal24036 Jan 13, 2026 https://github.com/python/cpython/pull/143738/commits/e3a54be56f0739c46983285a7825c35e80a1367c
9983345 Fix refcounting during groupby key comparison VanshAgarwal24036 Jan 13, 2026 https://github.com/python/cpython/pull/143738/commits/998334526afc8d636572e30a831697aaf6c2e70b
1ea51c0 Add NEWS entry via blurb for itertools.groupby crash VanshAgarwal24036 Jan 13, 2026 https://github.com/python/cpython/pull/143738/commits/1ea51c06d7afcdbded3acf9d50e4a90736c615a9
336c367 Fix duplicate variable declarations in groupby_next VanshAgarwal24036 Jan 13, 2026 https://github.com/python/cpython/pull/143738/commits/336c36748ab272ce0f980b19121084338d72772a
9cbe1a6 itertools: hold strong references during groupby key comparison VanshAgarwal24036 Jan 13, 2026 https://github.com/python/cpython/pull/143738/commits/9cbe1a6c3651ddde58eb9b388ff861a39205a058
8c61450 Clarify re-entrant groupby key comparison comment VanshAgarwal24036 Jan 14, 2026 https://github.com/python/cpython/pull/143738/commits/8c61450233d9cea60df098e63e9de4aead7d224c
90e995b Update Modules/itertoolsmodule.c VanshAgarwal24036 Jan 14, 2026 https://github.com/python/cpython/pull/143738/commits/90e995b1b817ca47ee17dc90d7e68bfa888811c2
4f2338f Update Lib/test/test_itertools.py VanshAgarwal24036 Jan 14, 2026 https://github.com/python/cpython/pull/143738/commits/4f2338f1c50fc29ffeed0da2d8491ad6f500a569
2cac26b Simplify groupby re-entrancy test VanshAgarwal24036 Jan 14, 2026 https://github.com/python/cpython/pull/143738/commits/2cac26be898e86976f2211387fd82e2a1cfa7236
fed7db7 Move rcmp declaration and clarify re-entrancy comment VanshAgarwal24036 Jan 14, 2026 https://github.com/python/cpython/pull/143738/commits/fed7db70b1fccd0e9d67fa3631c21ec0de3556c7
4939083 Move comment before declarations and inline rcmp VanshAgarwal24036 Jan 14, 2026 https://github.com/python/cpython/pull/143738/commits/4939083e12339646ff3dea681760e282b4fb0c74
e42b9b4 Remove Extra lines VanshAgarwal24036 Jan 14, 2026 https://github.com/python/cpython/pull/143738/commits/e42b9b419c30f47177b62188fbc9c6d287f4f801
e29c818 Remove extra Lines VanshAgarwal24036 Jan 15, 2026 https://github.com/python/cpython/pull/143738/commits/e29c8184917ff9936d8ff58f3858e9de73f9ecea
4be9d4f Update Lib/test/test_itertools.py VanshAgarwal24036 Feb 3, 2026 https://github.com/python/cpython/pull/143738/commits/4be9d4f3962a95354ce2d247cafd92bd8a5ae4af
b48d388 Merge branch 'main' into gh-143543-groupby-uaf encukou Feb 4, 2026 https://github.com/python/cpython/pull/143738/commits/b48d388d3e00a96505f828134734c52d2fadc848
Clear filters https://github.com/python/cpython/pull/143738/files
Please reload this pagehttps://github.com/python/cpython/pull/143738/files
Please reload this pagehttps://github.com/python/cpython/pull/143738/files
test_itertools.py https://github.com/python/cpython/pull/143738/files#diff-9abbaeca99112e9e04b554726bff97b76030eb982f39e591be77be8ef14149e5
2026-01-13-10-38-43.gh-issue-143543.DeQRCO.rst https://github.com/python/cpython/pull/143738/files#diff-894465dd65fd1dfc5ce3c2ade39be59ffeabc0ec9871ca6cbc251270a7d689fa
itertoolsmodule.c https://github.com/python/cpython/pull/143738/files#diff-dc27cbdf2b9f6e5236cade13cf301d352a7abd2a8b1988f2517d6f5b7a30c201
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L521
Lib/test/test_itertools.pyhttps://github.com/python/cpython/pull/143738/files#diff-9abbaeca99112e9e04b554726bff97b76030eb982f39e591be77be8ef14149e5
View file https://github.com/VanshAgarwal24036/cpython/blob/b48d388d3e00a96505f828134734c52d2fadc848/Lib/test/test_itertools.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/143738/{{ revealButtonHref }}
https://github.com/python/cpython/pull/143738/files#diff-9abbaeca99112e9e04b554726bff97b76030eb982f39e591be77be8ef14149e5
https://github.com/python/cpython/pull/143738/files#diff-9abbaeca99112e9e04b554726bff97b76030eb982f39e591be77be8ef14149e5
Misc/NEWS.d/next/Library/2026-01-13-10-38-43.gh-issue-143543.DeQRCO.rsthttps://github.com/python/cpython/pull/143738/files#diff-894465dd65fd1dfc5ce3c2ade39be59ffeabc0ec9871ca6cbc251270a7d689fa
View file https://github.com/VanshAgarwal24036/cpython/blob/b48d388d3e00a96505f828134734c52d2fadc848/Misc/NEWS.d/next/Library/2026-01-13-10-38-43.gh-issue-143543.DeQRCO.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/143738/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L522
Modules/itertoolsmodule.chttps://github.com/python/cpython/pull/143738/files#diff-dc27cbdf2b9f6e5236cade13cf301d352a7abd2a8b1988f2517d6f5b7a30c201
View file https://github.com/VanshAgarwal24036/cpython/blob/b48d388d3e00a96505f828134734c52d2fadc848/Modules/itertoolsmodule.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/143738/{{ revealButtonHref }}
https://github.com/python/cpython/pull/143738/files#diff-dc27cbdf2b9f6e5236cade13cf301d352a7abd2a8b1988f2517d6f5b7a30c201
Please reload this pagehttps://github.com/python/cpython/pull/143738/files
Please reload this pagehttps://github.com/python/cpython/pull/143738/files
https://github.com/python/cpython/pull/143738/files#diff-dc27cbdf2b9f6e5236cade13cf301d352a7abd2a8b1988f2517d6f5b7a30c201
Please reload this pagehttps://github.com/python/cpython/pull/143738/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.