Title: Use-after-free while pickling dicts · Issue #92930 · python/cpython · GitHub
Open Graph Title: Use-after-free while pickling dicts · Issue #92930 · python/cpython
X Title: Use-after-free while pickling dicts · Issue #92930 · python/cpython
Description: Found here, but this crash is unrelated, so opening a new issue. The following could be simplified, but it crashes because PyDict_Next creates borrowed references. import pickle from random import getrandbits class Bad: def __eq__(self, ...
Open Graph Description: Found here, but this crash is unrelated, so opening a new issue. The following could be simplified, but it crashes because PyDict_Next creates borrowed references. import pickle from random import ...
X Description: Found here, but this crash is unrelated, so opening a new issue. The following could be simplified, but it crashes because PyDict_Next creates borrowed references. import pickle from random import ...
Opengraph URL: https://github.com/python/cpython/issues/92930
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use-after-free while pickling dicts","articleBody":"Found [here](https://github.com/python/cpython/issues/90773), but this crash is unrelated, so opening a new issue.\r\n\r\nThe following could be simplified, but it crashes because PyDict_Next creates borrowed references.\r\n\r\n\r\n```python\r\nimport pickle\r\nfrom random import getrandbits\r\n\r\nclass Bad:\r\n def __eq__(self, other):\r\n if not ENABLED:\r\n return False\r\n break_things()\r\n return getrandbits(4) == 0\r\n def __hash__(self):\r\n return getrandbits(1)\r\n def __reduce__(self):\r\n break_things()\r\n return (Bad, (), ())\r\n def __setstate__(self, *args):\r\n break_things()\r\n def __del__(self):\r\n break_things()\r\n def __getattr__(self):\r\n break_things()\r\n\r\ndef break_things():\r\n if getrandbits(6) == 0:\r\n collection.clear()\r\n\r\nTRIALS = 10_000\r\nSIZE = 50\r\n\r\nfor i in range(TRIALS):\r\n try:\r\n ENABLED = False\r\n collection = {Bad():Bad() for _ in range(SIZE)}\r\n for bad in collection:\r\n bad.bad = bad\r\n bad.collection = collection\r\n ENABLED = True\r\n pickle.loads(pickle.dumps(collection))\r\n except RuntimeError as e:\r\n assert \"changed size during iteration\" in str(e)\r\n\r\nprint(\"ok\")\r\n```","author":{"url":"https://github.com/sweeneyde","@type":"Person","name":"sweeneyde"},"datePublished":"2022-05-18T18:06:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/92930/cpython/issues/92930"}
| 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:8d8a324d-ab9e-6c74-df3d-1014754c048a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 970A:556E7:5B84B8:7D50E9:69694CD6 |
| html-safe-nonce | d2be24b53c754f25ecb9bc985dcfd55e377697128026ee29335cab4563b7b834 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzBBOjU1NkU3OjVCODRCODo3RDUwRTk6Njk2OTRDRDYiLCJ2aXNpdG9yX2lkIjoiNTI3NDA5NzIyODUzMDE0MjQyMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7b954d8d41d3f4d6390667b5bef3363dbfc2ba9fbba8ad1f4692b4a231c74e77 |
| hovercard-subject-tag | issue:1240328150 |
| 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/92930/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b231941449dfc16cbea65b3311a9de0c03c55638b6ac12f978b5870bd80ed69b/python/cpython/issues/92930 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b231941449dfc16cbea65b3311a9de0c03c55638b6ac12f978b5870bd80ed69b/python/cpython/issues/92930 |
| og:image:alt | Found here, but this crash is unrelated, so opening a new issue. The following could be simplified, but it crashes because PyDict_Next creates borrowed references. import pickle from random import ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sweeneyde |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| 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 | d69ac0477df0f87da03b8b06cebd187012d7a930 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width