Title: Crash when using multiple capturing groups in `re.Scanner` · Issue #140797 · python/cpython · GitHub
Open Graph Title: Crash when using multiple capturing groups in `re.Scanner` · Issue #140797 · python/cpython
X Title: Crash when using multiple capturing groups in `re.Scanner` · Issue #140797 · python/cpython
Description: Bug report Bug description: The re.Scanner class crashes with a segmentation fault (memory corruption) when any pattern in the lexicon contains named capturing groups. import re lexicon = [ ('(?P
Open Graph Description: Bug report Bug description: The re.Scanner class crashes with a segmentation fault (memory corruption) when any pattern in the lexicon contains named capturing groups. import re lexicon = [ ('(?P X Description: Bug report Bug description: The re.Scanner class crashes with a segmentation fault (memory corruption) when any pattern in the lexicon contains named capturing groups. import re lexicon = [ ('(...
Opengraph URL: https://github.com/python/cpython/issues/140797
X: @github
Domain: github.com
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash when using multiple capturing groups in `re.Scanner`","articleBody":"# Bug report\n\n### Bug description:\n\nThe re.Scanner class crashes with a segmentation fault (memory corruption) when any pattern in the lexicon contains named capturing groups. \n\n```python\nimport re\n\nlexicon = [\n ('(?P\u003cgroup1\u003ea)(?P\u003cgroup2\u003eb)', None), # Named capturing groups\n]\n\nscanner = re.Scanner(lexicon)\nresult, leftover = scanner.scan(\"ab\") # Segmentation fault occurs here\n```\n\n```python\nzsh: segmentation fault python3 test.py\n```\n\nScanner should process the input normally and return scan results without crashing, but Python interpreter crashes with segmentation fault, indicating memory corruption.\n\n### CPython versions tested on:\n\n3.12\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-140944\n* gh-140982\n* gh-140983\n* gh-140984\n* gh-142231\n* gh-142309\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/T90REAL","@type":"Person","name":"T90REAL"},"datePublished":"2025-10-30T15:48:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":28},"url":"https://github.com/140797/cpython/issues/140797"}
route-pattern /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) route-controller voltron_issues_fragments route-action issue_layout fetch-nonce v2:89bbf0e3-a8b3-4fe7-6e66-bf87953ca839 current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id 98DA:AC611:194E6D5:22913EF:6964BA9E html-safe-nonce d5c5994eb0e35e955bac83a27e7d6d4b2b56bcf984aaf4b376be45aec7ae3d7d visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OERBOkFDNjExOjE5NEU2RDU6MjI5MTNFRjo2OTY0QkE5RSIsInZpc2l0b3JfaWQiOiI0MzkwODc3NzA1NjQ5MDQ0MTI2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= visitor-hmac 54d317512fe90bbe60d7fde4173c78f5811def4815ee7e03a071f9b9cb039a9b hovercard-subject-tag issue:3571408099 github-keyboard-shortcuts repository,issues,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/_view_fragments/issues/show/python/cpython/140797/issue_layout twitter:image https://opengraph.githubassets.com/3e9393bd507bc80504076e984ed01919045ff0aac725235c5576dfbd86ac5671/python/cpython/issues/140797 twitter:card summary_large_image og:image https://opengraph.githubassets.com/3e9393bd507bc80504076e984ed01919045ff0aac725235c5576dfbd86ac5671/python/cpython/issues/140797 og:image:alt Bug report Bug description: The re.Scanner class crashes with a segmentation fault (memory corruption) when any pattern in the lexicon contains named capturing groups. import re lexicon = [ ('(?P og:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username T90REAL hostname github.com expected-hostname github.com None 9917306ebdf5f9f30d13ede7b74f08a45b5f12b401ce3e4bfabd895ea0ca0ada turbo-cache-control no-preview 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 disable-turbo false browser-stats-url https://api.github.com/_private/browser/stats browser-errors-url https://api.github.com/_private/browser/errors release 020ceddb26807bba62dcfb410905847d63243ff5 ui-target full theme-color #1e2327 color-scheme light dark
URLs of crawlers that visited me.