Title: gh-146613: Fix re-entrant use-after-free in itertools._grouper by TheSkyC · Pull Request #147962 · python/cpython · GitHub
Open Graph Title: gh-146613: Fix re-entrant use-after-free in itertools._grouper by TheSkyC · Pull Request #147962 · python/cpython
X Title: gh-146613: Fix re-entrant use-after-free in itertools._grouper by TheSkyC · Pull Request #147962 · python/cpython
Description: Closes gh-146613 The same pattern was fixed in groupby.__next__ (gh-143543 / a91b5c3), but _grouper_next (the inner group iterator returned by groupby) was missed. A user-defined __eq__ can re-enter the grouper during PyObject_RichCompareBool, causing Py_XSETREF to free currkey while it is still being used. Fixed by taking strong references (Py_INCREF / Py_DECREF) to tgtkey and currkey before the comparison, exactly as done in groupby_next. Added regression test test_grouper_reentrant_eq_does_not_crash.
Open Graph Description: Closes gh-146613 The same pattern was fixed in groupby.__next__ (gh-143543 / a91b5c3), but _grouper_next (the inner group iterator returned by groupby) was missed. A user-defined __eq__ can re-ente...
X Description: Closes gh-146613 The same pattern was fixed in groupby.__next__ (gh-143543 / a91b5c3), but _grouper_next (the inner group iterator returned by groupby) was missed. A user-defined __eq__ can re-ente...
Opengraph URL: https://github.com/python/cpython/pull/147962
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:d4711072-c611-b60a-ed64-86f69770e2aa |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C19A:0B26:1AA8CD:236203:6A56E3A4 |
| html-safe-nonce | 23534ec3f8d02a683d93a323ff6fb0784cfaa4163dbc7457d4f221b440759fe2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTlBOjBCMjY6MUFBOENEOjIzNjIwMzo2QTU2RTNBNCIsInZpc2l0b3JfaWQiOiIyMDk4MTY5NTQ4MjU1OTc4NDA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 27e47cefb534d9fb59664d0bcc89ea58dd15f93a400465661c2c65394f879782 |
| hovercard-subject-tag | pull_request:3476606953 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/147962/files |
| twitter:image | https://avatars.githubusercontent.com/u/68433685?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/68433685?s=400&v=4 |
| og:image:alt | Closes gh-146613 The same pattern was fixed in groupby.__next__ (gh-143543 / a91b5c3), but _grouper_next (the inner group iterator returned by groupby) was missed. A user-defined __eq__ can re-ente... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5220a278731283038daf0ed00b41f06ef7ff9539020ecc806c5c5a0fb6bda25a |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8684ae1a81cd3e4ef219b241179982bbda1a5b1f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width