Title: Calling `ShareableList.count` in threads aborts: `Assertion 'self->exports == 0' failed` · Issue #127085 · python/cpython · GitHub
Open Graph Title: Calling `ShareableList.count` in threads aborts: `Assertion 'self->exports == 0' failed` · Issue #127085 · python/cpython
X Title: Calling `ShareableList.count` in threads aborts: `Assertion 'self->exports == 0' failed` · Issue #127085 · python/cpython
Description: Crash report What happened? It's possible to abort the interpreter by calling multiprocessing.shared_memory.ShareableList.count in threads with PYTHON_GIL=0 in a debug build: import gc import multiprocessing.shared_memory from threading ...
Open Graph Description: Crash report What happened? It's possible to abort the interpreter by calling multiprocessing.shared_memory.ShareableList.count in threads with PYTHON_GIL=0 in a debug build: import gc import multi...
X Description: Crash report What happened? It's possible to abort the interpreter by calling multiprocessing.shared_memory.ShareableList.count in threads with PYTHON_GIL=0 in a debug build: import gc import m...
Opengraph URL: https://github.com/python/cpython/issues/127085
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Calling `ShareableList.count` in threads aborts: `Assertion 'self-\u003eexports == 0' failed`","articleBody":"# Crash report\n\n### What happened?\n\nIt's possible to abort the interpreter by calling `multiprocessing.shared_memory.ShareableList.count` in threads with `PYTHON_GIL=0` in a debug build:\n\n```python\nimport gc\nimport multiprocessing.shared_memory\nfrom threading import Thread\n\nobj = multiprocessing.shared_memory.ShareableList(\"Uq..SeDAmB+EBrkLl.SG.Z+Z.ZdsV..wT+zLxKwdN\\b\")\n\nfor x in range(10):\n Thread(target=obj.count, args=(1,)).start()\n\ndel obj\ngc.collect()\n```\n\nResult:\n```python\nException ignored in: \u003cfunction SharedMemory.__del__ at 0x200006bbfb0\u003e\nTraceback (most recent call last):\n File \"/home/danzin/projects/mycpython/Lib/multiprocessing/shared_memory.py\", line 189, in __del__\n self.close()\n File \"/home/danzin/projects/mycpython/Lib/multiprocessing/shared_memory.py\", line 229, in close\n self._buf.release()\nBufferError: memoryview has 2 exported buffers\npython: Objects/memoryobject.c:1143: memory_dealloc: Assertion `self-\u003eexports == 0' failed.\nAborted\n```\nFound using [fusil](https://github.com/devdanzin/fusil) by @vstinner.\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.0a2+ experimental free-threading build (heads/main-dirty:c9b399fbdb0, Nov 19 2024, 20:12:48) [GCC 11.4.0]\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-127412\n* gh-128019\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/devdanzin","@type":"Person","name":"devdanzin"},"datePublished":"2024-11-21T02:00:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/127085/cpython/issues/127085"}
| 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:6e8d30dc-2c24-e419-c7b8-cda17412951f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 80BA:15F89A:22DD4BE:2F7463E:696AD178 |
| html-safe-nonce | 05dc4116d6d529bb7da4be2baf46969fb2e8c9d85d6aab507fe873e3b415e7d6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEJBOjE1Rjg5QToyMkRENEJFOjJGNzQ2M0U6Njk2QUQxNzgiLCJ2aXNpdG9yX2lkIjoiMjgxOTM0MjM0MzA0NTA0MjU1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 801b7f8ca621f8e487bc0b374fe2579e03a93566d61118bc6a5dbac70b48abe9 |
| hovercard-subject-tag | issue:2677710237 |
| 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/127085/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1ca32c6133021dce45e9467def0c61cfb861529becec2d9481220ed51938c9b/python/cpython/issues/127085 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1ca32c6133021dce45e9467def0c61cfb861529becec2d9481220ed51938c9b/python/cpython/issues/127085 |
| og:image:alt | Crash report What happened? It's possible to abort the interpreter by calling multiprocessing.shared_memory.ShareableList.count in threads with PYTHON_GIL=0 in a debug build: import gc import multi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devdanzin |
| hostname | github.com |
| expected-hostname | github.com |
| None | c785f4ce187e9e7331257791b36ddee01625bb8e292a9b4fe2c16d4c006abf5d |
| 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 | c718a376fcf780eb22089171adb84a543f660bf7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width