GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Immortalize Py_EMPTY_KEYS · Issue #104252 · python/cpython

Immortalize Py_EMPTY_KEYS #104252

New issue
Copy link
New issue
Copy link
Closed
Closed
Immortalize Py_EMPTY_KEYS#104252
Copy link
Labels
3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

Description

@ericsnowcurrently
ericsnowcurrently
opened on May 6, 2023
Issue body actions

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.

Every 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,

One way or another, we need to isolate Py_EMPTY_KEYS. Otherwise we end up with races on the refcount.

cc @eduardo-elizondo @markshannon


Possible solutions:

  1. update the code in dictobject.c to make Py_EMPTY_KEYS immortal
  2. move Py_EMPTY_KEYS to PyInterpreterState

The first one seems simpler.

Linked PRs

  • gh-104252: Immortalize Py_EMPTY_KEYS #104253

Activity

  1. ericsnowcurrently
    added
    type-featureA feature request or enhancementA feature request or enhancement
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    3.12only security fixesonly security fixes
    on May 6, 2023
  2. ericsnowcurrently
    added a commit that references this issue on May 10, 2023

    gh-104252: Immortalize Py_EMPTY_KEYS (gh-104253)

    b8f7ab5
  3. ericsnowcurrently
    closed this as completedon May 10, 2023
  4. carljm
    added 2 commits that reference this issue on May 10, 2023

    Merge branch 'main' into fixloadsuperspec

    5976df9

    Merge branch 'main' into supermon

    19b3d9e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.