Title: Missing recursion checks building long lazy import alias can segfault · Issue #159288 · python/cpython · GitHub
Open Graph Title: Missing recursion checks building long lazy import alias can segfault · Issue #159288 · python/cpython
X Title: Missing recursion checks building long lazy import alias can segfault · Issue #159288 · python/cpython
Description: Crash report Bug: When lazily importing a long dotted named module using an alias, nested placeholders are used for each name to build the full chain recursively. If the dotted module name is long enough (import a.b.c.d.etc as foo), it's...
Open Graph Description: Crash report Bug: When lazily importing a long dotted named module using an alias, nested placeholders are used for each name to build the full chain recursively. If the dotted module name is long ...
X Description: Crash report Bug: When lazily importing a long dotted named module using an alias, nested placeholders are used for each name to build the full chain recursively. If the dotted module name is long ...
Opengraph URL: https://github.com/python/cpython/issues/159288
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Missing recursion checks building long lazy import alias can segfault","articleBody":"### Crash report\n\n**Bug:** When lazily importing a long dotted named module using an alias, nested placeholders are used for each name to build the full chain recursively. If the dotted module name is long enough (`import a.b.c.d.etc as foo`), it's possible to overflow the C stack and segfault. \n\n**Severity:** It's likely that these use cases would rarely be hit, but _they do segfault_ when using lazy imports and they do not with eager imports, so I think it's still worth a small fix. \n\n### examples\n\nBoth tests leverage `threading` to reduce the available stack size. \n\nResolving from repr:\n```python\nimport threading\nexec(\"lazy import \" + \".\".join([\"m\"] * 10_000) + \" as x\")\nthreading.stack_size(256 * 1024)\nt = threading.Thread(target=repr, args=(globals()[\"x\"],))\nt.start(); t.join()\n```\n\n```\nSegmentation fault (core dumped)\n```\n----------------------\n\nResolving via a function call:\n```python\nimport threading\nexec(\"lazy import \" + \".\".join([\"m\"] * 10_000) + \" as x\")\ndef f():\n x\nthreading.stack_size(256 * 1024)\nt = threading.Thread(target=f)\nt.start(); t.join()\n```\n\n```\nSegmentation fault (core dumped)\n```\n\n### CPython versions tested on:\n\n3.15\n\n### Operating systems tested on:\n\nLinux\n\n### Output from running 'python -VV' on the command line:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-159289\n* gh-159416\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/brittanyrey","@type":"Person","name":"brittanyrey"},"datePublished":"2026-10-13T04:02:26Z","url":"https://github.com/python/cpython/issues/159288"}
| 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:92d4d8cc-ccc9-42b2-877c-fe626eb235f1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E702:1F68:1237E92:1856E3E:6B020E06 |
| html-safe-nonce | 47241ee85e4c832238b2d914cd49a35908f09de0945d57adbba5fc64ef3e621c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzAyOjFGNjg6MTIzN0U5MjoxODU2RTNFOjZCMDIwRTA2IiwidmlzaXRvcl9pZCI6IjIwNzMyNTAyMDgxNDUzNDYwNTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a5c5244de6a603bf1d12ed33e6d00c652d7475b0ebb950da11bf435e5a434df4 |
| hovercard-subject-tag | issue:5824301686 |
| 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/159288/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cd1b024b2be212d302bef8a687227edb15d7f1d5f718932590cdfe7199294e32/python/cpython/issues/159288 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cd1b024b2be212d302bef8a687227edb15d7f1d5f718932590cdfe7199294e32/python/cpython/issues/159288 |
| og:image:alt | Crash report Bug: When lazily importing a long dotted named module using an alias, nested placeholders are used for each name to build the full chain recursively. If the dotted module name is long ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | brittanyrey |
| 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