Title: segfault on recursive type · Issue #6730 · python/mypy · GitHub
Open Graph Title: segfault on recursive type · Issue #6730 · python/mypy
X Title: segfault on recursive type · Issue #6730 · python/mypy
Description: I'm running mypy 0.701 on Python 3.7.2 on Linux, with the following input: from typing import Any, Generic, Iterable, TypeVar, Union ValueT = TypeVar('ValueT') class Recursive(Iterable[Union[ValueT, 'Recursive[ValueT]']]): pass class Bas...
Open Graph Description: I'm running mypy 0.701 on Python 3.7.2 on Linux, with the following input: from typing import Any, Generic, Iterable, TypeVar, Union ValueT = TypeVar('ValueT') class Recursive(Iterable[Union[ValueT...
X Description: I'm running mypy 0.701 on Python 3.7.2 on Linux, with the following input: from typing import Any, Generic, Iterable, TypeVar, Union ValueT = TypeVar('ValueT') class Recursive(Iterable[...
Opengraph URL: https://github.com/python/mypy/issues/6730
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"segfault on recursive type","articleBody":"I'm running mypy 0.701 on Python 3.7.2 on Linux, with the following input:\r\n```py\r\nfrom typing import Any, Generic, Iterable, TypeVar, Union\r\n\r\nValueT = TypeVar('ValueT')\r\n\r\nclass Recursive(Iterable[Union[ValueT, 'Recursive[ValueT]']]):\r\n pass\r\n\r\nclass Base(Generic[ValueT]):\r\n def __init__(self, element: ValueT):\r\n pass\r\n\r\nclass Sub(Base[Union[ValueT, Recursive[ValueT]]]):\r\n pass\r\n\r\nx: Iterable[str]\r\nprint(Sub(x))\r\n```\r\nI ran mypy under gdb to get a stack trace, but the stack trace is over 70,000 frames long (the point at which I aborted its listing), so I don't think including the full thing would be feasible or useful.\r\n\r\nIt looks like the following pattern is repeated over and over:\r\n```\r\n#70084 0x00007ffff5f0d32f in CPyDef_types_accept_Instance (cpy_r_self=0x0, cpy_r_visitor=\u003coptimized out>) at build/__native.c:1601677\r\n#70085 0x00007ffff5db4b84 in CPyDef_subtypes_is_proper_subtype (cpy_r_left=0x7fffe766a6d8, cpy_r_right=\u003coptimized out>, cpy_r_ignore_promotions=\u003coptimized out>) at build/__native.c:1474319\r\n#70086 0x00007ffff5d79820 in CPyDef_types_make_simplified_union_UnionType (cpy_r_items=\u003coptimized out>, cpy_r_line=\u003coptimized out>, cpy_r_column=\u003coptimized out>) at build/__native.c:1626562\r\n#70087 0x00007ffff5f26ccd in CPyDef_expandtype_visit_union_type_ExpandTypeVisitor (cpy_r_self=\u003coptimized out>, cpy_r_t=0x7fffe8294f48) at build/__native.c:388697\r\n#70088 0x00007ffff5f26e06 in CPyDef_expandtype_visit_union_type__TypeVisitor_glue_ExpandTypeVisitor (cpy_r_self=0x8af200 \u003cPyDict_Type>, cpy_r_t=0x7ffff6ccec00) at build/__native.c:388750\r\n#70089 0x00007ffff65bac5f in CPyDef_types_accept_UnionType (cpy_r_self=0x0, cpy_r_visitor=\u003coptimized out>) at build/__native.c:1626978\r\n#70090 0x00007ffff5f24be7 in CPyDef_expandtype_expand_types_ExpandTypeVisitor (cpy_r_self=0x7fffe76e5870, cpy_r_types=\u003coptimized out>) at build/__native.c:389037\r\n#70091 0x00007ffff5f2481f in CPyDef_expandtype_visit_instance_ExpandTypeVisitor (cpy_r_self=0x7fffe76e5870, cpy_r_t=0x7fffe7d5cf28) at build/__native.c:387615\r\n#70092 0x00007ffff5f24e36 in CPyDef_expandtype_visit_instance__TypeVisitor_glue_ExpandTypeVisitor (cpy_r_self=0x8af200 \u003cPyDict_Type>, cpy_r_t=0x7ffff6ccec00) at build/__native.c:387706\r\n#70093 0x00007ffff5f0d32f in CPyDef_types_accept_Instance (cpy_r_self=0x0, cpy_r_visitor=\u003coptimized out>) at build/__native.c:1601677\r\n#70094 0x00007ffff5c4ef15 in CPyDef_expandtype_expand_type (cpy_r_typ=0x7fffe7d5cf28, cpy_r_env=0x7fffe76e5828) at build/__native.c:386276\r\n#70095 0x00007ffff5ff068b in CPyDef_maptype_map_instance_to_direct_supertypes (cpy_r_instance=0x7fffe766a588, cpy_r_supertype=0x7fffe858b258) at build/__native.c:519519\r\n#70096 0x00007ffff5fef535 in CPyDef_maptype_map_instance_to_supertypes (cpy_r_instance=\u003coptimized out>, cpy_r_supertype=\u003coptimized out>) at build/__native.c:518873\r\n#70097 0x00007ffff5d9d105 in CPyDef_maptype_map_instance_to_supertype (cpy_r_instance=0x7fffe766a588, cpy_r_superclass=0x7fffe858b258) at build/__native.c:518619\r\n#70098 0x00007ffff6509a9c in CPyDef_subtypes_visit_instance_ProperSubtypeVisitor (cpy_r_self=\u003coptimized out>, cpy_r_left=\u003coptimized out>) at build/__native.c:1475884\r\n#70099 0x00007ffff650aff6 in CPyDef_subtypes_visit_instance__TypeVisitor_glue_ProperSubtypeVisitor (cpy_r_self=0x8af200 \u003cPyDict_Type>, cpy_r_t=0x7ffff6ccec00) at build/__native.c:1476491\r\n```\r\n\r\nI guess the compiled part of mypy got into an infinite recursion trying to figure out the recursive type definition and eventually hit a system limit on the native stack size.","author":{"url":"https://github.com/mthuurne","@type":"Person","name":"mthuurne"},"datePublished":"2019-04-27T02:01:11Z","url":"https://github.com/python/mypy/issues/6730"}
| 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:aaf46e37-ea4f-46f1-314f-be51418d0403 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8886:2B9B04:288067E:352275C:6B000A5D |
| html-safe-nonce | 5fe7fc9ec3b7cef2821a3987e39f930267661b20dbca792e11ca5de76cffedbc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODg2OjJCOUIwNDoyODgwNjdFOjM1MjI3NUM6NkIwMDBBNUQiLCJ2aXNpdG9yX2lkIjoiNzA3NTc5MDQ2MTEwMDYyNDQ3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7b529da32cf0c259742e5994f3ec8455f405ebbd34429ca6858ccad8ec3c3e99 |
| hovercard-subject-tag | issue:437894675 |
| 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/mypy/6730/issue_layout |
| twitter:image | https://opengraph.githubassets.com/45cf467a431e272ea27d12bb3b528d5cc1656f68e4765af85a466082a51d2b6e/python/mypy/issues/6730 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/45cf467a431e272ea27d12bb3b528d5cc1656f68e4765af85a466082a51d2b6e/python/mypy/issues/6730 |
| og:image:alt | I'm running mypy 0.701 on Python 3.7.2 on Linux, with the following input: from typing import Any, Generic, Iterable, TypeVar, Union ValueT = TypeVar('ValueT') class Recursive(Iterable[Union[ValueT... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mthuurne |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width