Title: v3.13.0rc2 Segmentation Fault in gc.get_referents. PyCapsule->traverse_func is NULL · Issue #124538 · python/cpython · GitHub
Open Graph Title: v3.13.0rc2 Segmentation Fault in gc.get_referents. PyCapsule->traverse_func is NULL · Issue #124538 · python/cpython
X Title: v3.13.0rc2 Segmentation Fault in gc.get_referents. PyCapsule->traverse_func is NULL · Issue #124538 · python/cpython
Description: Crash report What happened? Hello! Thank you for all your work on CPython. Hopefully this crash report is helpful. While working on matplotlib/matplotlib#28861, we noticed that our tests were segfaulting, and only on python3.13. Here is ...
Open Graph Description: Crash report What happened? Hello! Thank you for all your work on CPython. Hopefully this crash report is helpful. While working on matplotlib/matplotlib#28861, we noticed that our tests were segfa...
X Description: Crash report What happened? Hello! Thank you for all your work on CPython. Hopefully this crash report is helpful. While working on matplotlib/matplotlib#28861, we noticed that our tests were segfa...
Opengraph URL: https://github.com/python/cpython/issues/124538
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"v3.13.0rc2 Segmentation Fault in gc.get_referents. PyCapsule-\u003etraverse_func is NULL","articleBody":"# Crash report\r\n\r\n### What happened?\r\n\r\nHello! Thank you for all your work on CPython. Hopefully this crash report is helpful.\r\n\r\nWhile working on https://github.com/matplotlib/matplotlib/pull/28861, we noticed that our tests were segfaulting, and only on python3.13. Here is a minimal reproduction of that crash. I've also run it with python3.13-dbg and `-X dev` to hopefully provide more details.\r\n\r\n**Error Message**\r\n```\r\npython: ../Objects/capsule.c:321: capsule_traverse: Assertion `capsule-\u003etraverse_func != NULL' failed.\r\n```\r\n\r\n**Minimal Reproducible Example:**\r\n```console\r\n$ python3.13 -m venv venv_313\r\n$ source venv_313/bin/activate\r\n$ pip install matplotlib==3.9.2\r\n$ python -X dev test.py\r\n```\r\n\r\n**test.py**\r\n```python\r\nimport gc\r\nfrom collections import deque\r\nfrom matplotlib.figure import Figure\r\nfrom matplotlib.lines import Line2D\r\nfrom matplotlib.collections import PathCollection\r\n\r\ndef get_children(parent):\r\n if parent.__class__.__qualname__ == \"PyCapsule\":\r\n print(f\"About to call gc.get_referents on {repr(parent)}\")\r\n children = gc.get_referents(parent) # gc.get_referrers does not segfault, but gc.get_referents does\r\n if parent.__class__.__qualname__ == \"PyCapsule\":\r\n print(f\"There are {len(children)} children\")\r\n return children\r\n\r\ndef breadth_first_search(start):\r\n to_visit = deque([start])\r\n explored = set()\r\n try:\r\n gc.disable() # Can repro without this, but it should make behavior more consistent\r\n while len(to_visit) \u003e 0:\r\n parent = to_visit.popleft()\r\n for child in get_children(parent):\r\n if id(child) in explored:\r\n continue\r\n explored.add(id(child))\r\n to_visit.append(child)\r\n finally:\r\n gc.enable()\r\n\r\ndef find_reference_cycles():\r\n fig = Figure()\r\n ax = fig.add_subplot()\r\n ax.plot([1])\r\n fig.clear()\r\n breadth_first_search(fig)\r\n\r\nif __name__ == \"__main__\":\r\n find_reference_cycles()\r\n```\r\n\r\nwith python3.13 on Ubuntu 22.04.4\r\n```console\r\n$ python -VV\r\nPython 3.13.0rc2 (main, Sep 9 2024, 22:55:42) [GCC 11.4.0]\r\n$ python -X dev test.py\r\nAbout to call gc.get_referents on \u003ccapsule object \"pybind11_function_record_capsule\" at 0x7f79954f34d0\u003e\r\nFatal Python error: Segmentation fault\r\n\r\nCurrent thread 0x00007f79e687f280 (most recent call first):\r\n File \"/home/justin/tmp/matplotlib_py313_segfault/test.py\", line 10 in get_children\r\n File \"/home/justin/tmp/matplotlib_py313_segfault/test.py\", line 22 in breadth_first_search\r\n File \"/home/justin/tmp/matplotlib_py313_segfault/test.py\", line 35 in find_reference_cycles\r\n File \"/home/justin/tmp/matplotlib_py313_segfault/test.py\", line 38 in \u003cmodule\u003e\r\n\r\nExtension modules: numpy._core._multiarray_umath, numpy.linalg._umath_linalg, PIL._imaging, kiwisolver._cext (total: 4)\r\nSegmentation fault (core dumped)\r\n```\r\n\r\nwith python3.13-dbg on Ubuntu 22.04.4:\r\n```console\r\n$ python -VV\r\nPython 3.13.0rc2 (main, Sep 9 2024, 22:55:42) [GCC 11.4.0]\r\n$ python -X dev test.py\r\nAbout to call gc.get_referents on \u003ccapsule object \"pybind11_function_record_capsule\" at 0x7f0c31adba80\u003e\r\npython: ../Objects/capsule.c:321: capsule_traverse: Assertion `capsule-\u003etraverse_func != NULL' failed.\r\nFatal Python error: Aborted\r\n\r\nCurrent thread 0x00007f0c82d1a280 (most recent call first):\r\n File \"/home/justin/tmp/matplotlib_py313_segfault/test.py\", line 10 in get_children\r\n File \"/home/justin/tmp/matplotlib_py313_segfault/test.py\", line 22 in breadth_first_search\r\n File \"/home/justin/tmp/matplotlib_py313_segfault/test.py\", line 35 in find_reference_cycles\r\n File \"/home/justin/tmp/matplotlib_py313_segfault/test.py\", line 38 in \u003cmodule\u003e\r\n\r\nExtension modules: numpy._core._multiarray_umath, numpy.linalg._umath_linalg, PIL._imaging, kiwisolver._cext (total: 4)\r\nAborted (core dumped)\r\n```\r\n\r\nIt does not crash with python3.12 on Ubuntu 22.04.4\r\n```console\r\n$ python -VV\r\nPython 3.12.6 (main, Sep 10 2024, 00:05:17) [GCC 11.4.0]\r\n\r\n$ python -X dev test.py\r\nAbout to call gc.get_referents on \u003ccapsule object \"pybind11_function_record_capsule\" at 0x7f85a852a570\u003e\r\nThere are 0 children\r\n[ ... many similar log lines removed ... ]\r\n```\r\n\r\nSide-note:\r\nI tested this on both python3.12 and 3.13, but not the main branch. The Github Issue dropdown doesn't have a 3.13rc2 option for me to check.\r\n\r\n### CPython versions tested on:\r\n\r\n3.12\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\r\n\r\n### Output from running 'python -VV' on the command line:\r\n\r\nPython 3.13.0rc2 (main, Sep 9 2024, 22:55:42) [GCC 11.4.0]\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-124559\r\n* gh-124588\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/justinjhendrick","@type":"Person","name":"justinjhendrick"},"datePublished":"2024-09-25T19:29:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/124538/cpython/issues/124538"}
| 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:c4518937-97da-74c6-2d54-1a2f62ebc3a4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A88:E1D0E:1204541:17B65D0:696B736A |
| html-safe-nonce | 03cd2c8fc283dc2ef0f9e122ea57364c0683d08e9e304f2213af7877f3a510f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTg4OkUxRDBFOjEyMDQ1NDE6MTdCNjVEMDo2OTZCNzM2QSIsInZpc2l0b3JfaWQiOiIyOTcxOTE5ODMyMTY5ODA0NjUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | bce70c9ff8c15c1f8c62b0134d630ef6eb4b91b26edbc860dcfd1a7a31281db6 |
| hovercard-subject-tag | issue:2548837823 |
| 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/124538/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2ae6b80d1538f22dc14945cc733f5ef669d3316361d0649a257bace05150aa75/python/cpython/issues/124538 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2ae6b80d1538f22dc14945cc733f5ef669d3316361d0649a257bace05150aa75/python/cpython/issues/124538 |
| og:image:alt | Crash report What happened? Hello! Thank you for all your work on CPython. Hopefully this crash report is helpful. While working on matplotlib/matplotlib#28861, we noticed that our tests were segfa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | justinjhendrick |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width