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 — Data race with Context ctx_vars under free-threading · Issue #155519 · python/cpython

Data race with Context ctx_vars under free-threading #155519

New issue
Copy link
New issue
Copy link
Closed
Closed
Data race with Context ctx_vars under free-threading#155519
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@nascheme
nascheme
opened on Aug 10, 2026
Issue body actions

Bug report

Bug description:

The HAMT held by a context is immutable, but the pointer to it is not: contextvar_set() and contextvar_del() install a new HAMT and drop the reference to the previous one. Only the thread that entered a context can do that (a context cannot be entered by two threads at once), but any thread can read a context object at any time -- ctx.copy(), len(ctx), ctx.items(), etc. Such a reader has to acquire its own reference to the HAMT under the context's lock; reading ctx_vars unlocked lets the writer deallocate the HAMT while the reader is walking it.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

  • gh-155519: fix data-race for Context.ctx_vars #155522
  • [3.14] gh-155519: fix data-race for Context.ctx_vars (GH-155522) #155892
  • [3.15] gh-155519: fix data-race for Context.ctx_vars (GH-155522) #155893

Activity

  1. nascheme
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-free-threading
    on Aug 10, 2026
  2. aisk
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Aug 11, 2026
  3. kumaraditya303
    added a commit that references this issue on Aug 15, 2026

    gh-155519: fix data-race for Context.ctx_vars (#155522)

    9ee248c
  4. hugovk
    added a commit that references this issue on Aug 19, 2026

    [3.15] gh-155519: fix data-race for Context.ctx_vars (GH-155522) (#15…

    9d0e268
  5. kumaraditya303
    added a commit that references this issue on Aug 20, 2026

    [3.14] gh-155519: fix data-race for Context.ctx_vars (GH-155522) (#15…

    8854fbc
  6. kumaraditya303
    closed this as completedon Aug 20, 2026
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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-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.