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 — Fix thread-safety of interpreter cached object `str_replace_inf` (free threading) · Issue #125268 · python/cpython

Fix thread-safety of interpreter cached object str_replace_inf (free threading) #125268

New issue
Copy link
New issue
Copy link
Closed
Closed
Fix thread-safety of interpreter cached object str_replace_inf (free threading)#125268
Copy link
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@colesbury
colesbury
opened on Oct 10, 2024
Issue body actions

Bug report

We have a number of per-interpreter cached objects. Some of these are lazily initialized in a way that is not thread-safe in the free threading build. (See #125221, for example).

We should go through the remaining ones and make sure they are thread-safe.

EDIT: The only remaining field is str_replace_inf. Accesses to type_slots_pname and type_slots_ptrs are protected by a lock and the TypeVar fields are initialized once early on with other types.

cpython/Include/internal/pycore_global_objects.h

Lines 63 to 85 in 01fc3b3

#define _Py_INTERP_CACHED_OBJECT(interp, NAME) \
(interp)->cached_objects.NAME
struct _Py_interp_cached_objects {
PyObject *interned_strings;
/* AST */
PyObject *str_replace_inf;
/* object.__reduce__ */
PyObject *objreduce;
PyObject *type_slots_pname;
pytype_slotdef *type_slots_ptrs[MAX_EQUIV];
/* TypeVar and related types */
PyTypeObject *generic_type;
PyTypeObject *typevar_type;
PyTypeObject *typevartuple_type;
PyTypeObject *paramspec_type;
PyTypeObject *paramspecargs_type;
PyTypeObject *paramspeckwargs_type;
PyTypeObject *constevaluator_type;
};

Linked PRs

  • gh-125268: Use static string for "1e309" in AST #125272
  • [3.13] gh-125268: Use static string for "1e309" in AST (GH-125272) #125280

Activity

  1. colesbury
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    3.13only security fixesonly security fixes
    topic-free-threading
    3.14bugs and security fixesbugs and security fixes
    on Oct 10, 2024
  2. colesbury commented on Oct 10, 2024

    @colesbury
    colesbury
    on Oct 10, 2024
    ContributorAuthor
    More actions

    The "TypeVar and related types" fields are initialized during interpreter start-up, so they're fine.

  3. colesbury
    added a commit that references this issue on Oct 10, 2024

    pythongh-125268: Use static string for "1e309" in AST

    3a9e16e
  4. colesbury
    changed the title [-]Thread-safety of interpreter cached objects (free threading)[/-] [+]Fix thread-safety of interpreter cached object `str_replace_inf` (free threading)[/+] on Oct 10, 2024
  5. colesbury
    added 2 commits that reference this issue on Oct 10, 2024

    gh-125268: Use static string for "1e309" in AST (#125272)

    427dcf2

    [3.13] pythongh-125268: Use static string for "1e309" in AST (pythonG…

    cd1f221
  6. colesbury
    added a commit that references this issue on Oct 24, 2024

    [3.13] gh-125268: Use static string for "1e309" in AST (GH-125272) (G…

    4b55d53
  7. kumaraditya303
    closed this as completedon Oct 26, 2024
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.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    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.