Title: Immortalize Py_EMPTY_KEYS · Issue #104252 · python/cpython · GitHub
Open Graph Title: Immortalize Py_EMPTY_KEYS · Issue #104252 · python/cpython
X Title: Immortalize Py_EMPTY_KEYS · Issue #104252 · python/cpython
Description: The every dict has a keys "object", of type PyDictKeysObject. While it isn't actually a Python object, it does have a refcount, which is used to know when to free it. PyDictKeysObject (and the helpers, dictkeys_incref() and dictkeys_decr...
Open Graph Description: The every dict has a keys "object", of type PyDictKeysObject. While it isn't actually a Python object, it does have a refcount, which is used to know when to free it. PyDictKeysObject (and the help...
X Description: The every dict has a keys "object", of type PyDictKeysObject. While it isn't actually a Python object, it does have a refcount, which is used to know when to free it. PyDictKeysObject...
Opengraph URL: https://github.com/python/cpython/issues/104252
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Immortalize Py_EMPTY_KEYS","articleBody":"The every dict has a keys \"object\", of type `PyDictKeysObject`. While it isn't actually a Python object, it does have a refcount, which is used to know when to free it. `PyDictKeysObject` (and the helpers, `dictkeys_incref()` and `dictkeys_decref()`) was not updated to be immortal when the other singletons were. When it comes to interpreter isolation, that's a problem for empty dicts.\r\n\r\nEvery empty dict shares a global, statically allocated singleton for its keys: `Py_EMPTY_KEYS` (AKA `static PyDictKeysObject empty_keys_struct`). This singleton is defined and used internally in dictobject.c, so we don't have the same ABI compatibility concerns that we have with object ref counts generally,\r\n\r\nOne way or another, we need to isolate `Py_EMPTY_KEYS`. Otherwise we end up with races on the refcount.\r\n\r\ncc @eduardo-elizondo @markshannon\r\n\r\n----\r\n\r\nPossible solutions:\r\n\r\n1. update the code in dictobject.c to make `Py_EMPTY_KEYS` immortal\r\n2. move `Py_EMPTY_KEYS` to `PyInterpreterState`\r\n\r\nThe first one seems simpler.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-104253\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/ericsnowcurrently","@type":"Person","name":"ericsnowcurrently"},"datePublished":"2023-05-06T23:49:46.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/104252/cpython/issues/104252"}
| 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:2d951d41-e364-5840-440a-40ffd0b03de0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B2C4:16B648:200168:2CEFBA:696A0651 |
| html-safe-nonce | 38dc15ef3dffe2359a121682306b3eefc1c05c91c9120b91593d8470199b94ab |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkM0OjE2QjY0ODoyMDAxNjg6MkNFRkJBOjY5NkEwNjUxIiwidmlzaXRvcl9pZCI6IjYyODY3NDYzNzI1NTk5OTY0OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e5b4e7b504a0cd2a18f12839a94b42afba0c66b2f87fecac6647920fe3a72909 |
| hovercard-subject-tag | issue:1698819298 |
| 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/104252/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f0058ae26c1e2ca2992d5bdef86bd29ce3a126f291ce78832f714163ba266ff7/python/cpython/issues/104252 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f0058ae26c1e2ca2992d5bdef86bd29ce3a126f291ce78832f714163ba266ff7/python/cpython/issues/104252 |
| og:image:alt | The every dict has a keys "object", of type PyDictKeysObject. While it isn't actually a Python object, it does have a refcount, which is used to know when to free it. PyDictKeysObject (and the help... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ericsnowcurrently |
| hostname | github.com |
| expected-hostname | github.com |
| None | 578c119ff0247c8b2f2491fbf4fc0395cdf909d4df66598cebdc96ddfc4418dc |
| 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 | 671c2f67171dbced24284331f3133a613d08c366 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width