Title: Segfault with async generator expressions · Issue #149122 · python/cpython · GitHub
Open Graph Title: Segfault with async generator expressions · Issue #149122 · python/cpython
X Title: Segfault with async generator expressions · Issue #149122 · python/cpython
Description: Crash report What happened? Running: tuple(await 2 for _ in []) on main causes a segfault: backtrace (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) * frame #0: 0x000000000000000...
Open Graph Description: Crash report What happened? Running: tuple(await 2 for _ in []) on main causes a segfault: backtrace (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, ad...
X Description: Crash report What happened? Running: tuple(await 2 for _ in []) on main causes a segfault: backtrace (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (co...
Opengraph URL: https://github.com/python/cpython/issues/149122
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Segfault with async generator expressions","articleBody":"# Crash report\n\n### What happened?\n\nRunning:\n```python\ntuple(await 2 for _ in [])\n```\non main causes a segfault:\n\u003cdetails>\n\u003csummary>backtrace\u003c/summary>\n\n```\n(lldb) bt\n* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)\n * frame #0: 0x0000000000000000\n frame #1: 0x00000001001b1e34 python.exe`_PyForIter_VirtualIteratorNext(tstate=0x00000001004df800, frame=0x0000000100678020, iter=\u003cunavailable>, index_ptr=\u003cunavailable>) at ceval.c:3717:22 [opt]\n frame #2: 0x00000001001aa02c python.exe`_PyEval_EvalFrameDefault(tstate=\u003cunavailable>, frame=0x0000000100678020, throwflag=\u003cunavailable>) at generated_cases.c.h:6093:36 [opt]\n frame #3: 0x00000001001a2ff4 python.exe`_PyEval_EvalFrame(tstate=0x00000001004df800, frame=\u003cunavailable>, throwflag=0) at pycore_ceval.h:118:16 [opt] [inlined]\n frame #4: 0x00000001001a2fe8 python.exe`_PyEval_Vector(tstate=0x00000001004df800, func=0x000000010514b530, locals=0x000000010514e540, args=0x0000000000000000, argcount=0, kwnames=0x0000000000000000) at ceval.c:2124:12 [opt] [inlined]\n frame #5: 0x00000001001a2fe8 python.exe`PyEval_EvalCode(co=\u003cunavailable>, globals=0x000000010514e540, locals=0x000000010514e540) at ceval.c:686:21 [opt]\n frame #6: 0x0000000100225080 python.exe`run_eval_code_obj(tstate=\u003cunavailable>, co=\u003cunavailable>, globals=\u003cunavailable>, locals=\u003cunavailable>) at pythonrun.c:1369:12 [opt] [artificial]\n frame #7: 0x0000000100224ec0 python.exe`run_mod(mod=0x00000008ec416678, filename=0x00000001050f68d0, globals=0x000000010514e540, locals=\u003cunavailable>, flags=\u003cunavailable>, arena=0x000000010503a2f0, interactive_src=\u003cunavailable>, generate_new_source=\u003cunavailable>) at pythonrun.c:1472:19 [opt]\n frame #8: 0x0000000100222108 python.exe`pyrun_file(fp=0x0000000203f788d0, filename=0x00000001050f68d0, start=257, globals=0x000000010514e540, locals=0x000000010514e540, closeit=1, flags=0x000000016fdfe7f8) at pythonrun.c:1296:15 [opt] [inlined]\n frame #9: 0x000000010022209c python.exe`_PyRun_SimpleFileObject(fp=0x0000000203f788d0, filename=0x00000001050f68d0, closeit=1, flags=0x000000016fdfe7f8) at pythonrun.c:518:13 [opt]\n frame #10: 0x0000000100221ad8 python.exe`_PyRun_AnyFileObject(fp=0x0000000203f788d0, filename=0x00000001050f68d0, closeit=1, flags=0x000000016fdfe7f8) at pythonrun.c:81:15 [opt]\n frame #11: 0x000000010024baf0 python.exe`pymain_run_file_obj(program_name=0x00000001050f69c0, filename=0x00000001050f68d0, skip_source_first_line=0) at main.c:411:15 [opt] [inlined]\n frame #12: 0x000000010024bab4 python.exe`pymain_run_file(config=0x00000001004aa820) at main.c:430:15 [opt]\n frame #13: 0x000000010024b34c python.exe`pymain_run_python(exitcode=0x000000016fdfe8d4) at main.c:715:21 [opt] [inlined]\n frame #14: 0x000000010024af2c python.exe`Py_RunMain at main.c:796:5 [opt]\n frame #15: 0x000000010024b644 python.exe`pymain_main(args=0x000000016fdfebe0) at main.c:826:12 [opt]\n frame #16: 0x000000010024b6e4 python.exe`Py_BytesMain(argc=\u003cunavailable>, argv=\u003cunavailable>) at main.c:850:12 [opt]\n frame #17: 0x00000001978e1d54 dyld`start + 7184\n(lldb)\n```\n\n\u003c/details>\n\nThe regression was introduced by:\nhttps://github.com/python/cpython/issues/131738: optimize builtin any/all/tuple calls with a generator expression arg (https://github.com/python/cpython/pull/131737)\n\nI'm guessing the missing syntax check means we have an async iter inside the call, and the optimized path is assunming it's a sync iter? I'm not an expert here.\n\nReproducible on Macos and linux builds.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n### Output from running 'python -VV' on the command line:\n\nPython 3.14.3 (main, Feb 19 2026, 15:40:46) [Clang 17.0.0 (clang-1700.6.3.2)]\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-149138\n* gh-149151\n* gh-149179\n* gh-149181\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/stestagg","@type":"Person","name":"stestagg"},"datePublished":"2026-04-29T00:33:38Z","url":"https://github.com/python/cpython/issues/149122"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:dbf7c99a-0045-b07f-ccfe-0c85420ec754 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9EC0:7A60E:3C2DEC6:4D2E22C:6B020766 |
| html-safe-nonce | 5f6df51dd0fb201d8383ca17444adf807053a89d37185bbd8a89fefd328ac1a0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RUMwOjdBNjBFOjNDMkRFQzY6NEQyRTIyQzo2QjAyMDc2NiIsInZpc2l0b3JfaWQiOiIxOTEyOTcyODk0OTI1ODgzMjM5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8ad139a30f2725bd3c1b27b9f741b1dadd0048360df75d4d846b7c561906342e |
| hovercard-subject-tag | issue:4347110533 |
| 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/149122/issue_layout |
| twitter:image | https://opengraph.githubassets.com/45f951038f4bae49c64bdd2cb109f48f1a3bb70500bff79590d21669568fd319/python/cpython/issues/149122 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/45f951038f4bae49c64bdd2cb109f48f1a3bb70500bff79590d21669568fd319/python/cpython/issues/149122 |
| og:image:alt | Crash report What happened? Running: tuple(await 2 for _ in []) on main causes a segfault: backtrace (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, ad... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | stestagg |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width