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 — gh-144446: Fix some frame object thread-safety issues by colesbury · Pull Request #144479 · python/cpython

Conversation

@colesbury

@colesbury colesbury commented Feb 4, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fix thread-safety issues when accessing frame attributes while another thread is executing the frame:

  • Add critical section to frame_repr() to prevent races when accessing the frame's code object and line number

  • Add _Py_NO_SANITIZE_THREAD to PyUnstable_InterpreterFrame_GetLasti() to allow intentional racy reads of instr_ptr.

  • Fix take_ownership() to not write to the original frame's f_executable

  • Issue: Data races with frame objects #144446

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@colesbury
pythongh-144446: Fix some frame object thread-safety issues
25f9328
Fix thread-safety issues when accessing frame attributes while another
thread is executing the frame:

- Add critical section to frame_repr() to prevent races when accessing
  the frame's code object and line number

- Add _Py_NO_SANITIZE_THREAD to PyUnstable_InterpreterFrame_GetLasti()
  to allow intentional racy reads of instr_ptr.

- Fix take_ownership() to not write to the original frame's f_executable
@bedevere-app bedevere-app Bot mentioned this pull request Feb 4, 2026
Data races with frame objects #144446
Open
2 of 3 tasks
@colesbury colesbury added the topic-free-threading label Feb 4, 2026
@colesbury
Fix blurb
ce6f092
@colesbury

colesbury commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

There are still some races when accessing variables through frame.f_locals, which will be address separately.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@colesbury
colesbury marked this pull request as ready for review February 4, 2026 18:08
@colesbury
colesbury requested a review from markshannon as a code owner February 4, 2026 18:08
@bedevere-app bedevere-app Bot added the awaiting core review label Feb 4, 2026
@colesbury
colesbury requested a review from mpage February 4, 2026 18:37
@colesbury colesbury added the needs backport to 3.14 bugs and security fixes label Feb 4, 2026
kumaraditya303
kumaraditya303 reviewed Feb 5, 2026
View reviewed changes
Comment thread Lib/test/test_free_threading/test_frame.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov reviewed Feb 5, 2026
View reviewed changes
Comment thread Python/frame.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@colesbury
Change test docstrings to comments
c6e8294
mpage
mpage approved these changes Feb 6, 2026
View reviewed changes

@mpage mpage left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Feb 6, 2026
kumaraditya303
kumaraditya303 approved these changes Feb 6, 2026
View reviewed changes
@colesbury
colesbury merged commit 5bb3bbb into python:main Feb 6, 2026
51 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@colesbury
colesbury deleted the gh-144446-frame-free-threading branch February 6, 2026 14:43
@bedevere-app bedevere-app Bot removed the awaiting merge label Feb 6, 2026
@miss-islington-app

miss-islington-app Bot commented Feb 6, 2026

Copy link
Copy Markdown

Thanks @colesbury for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 6, 2026
@colesbury @miss-islington
pythongh-144446: Fix some frame object thread-safety issues (pythongh…
d92a7fb
…-144479)

Fix thread-safety issues when accessing frame attributes while another
thread is executing the frame:

- Add critical section to frame_repr() to prevent races when accessing
  the frame's code object and line number

- Add _Py_NO_SANITIZE_THREAD to PyUnstable_InterpreterFrame_GetLasti()
  to allow intentional racy reads of instr_ptr.

- Fix take_ownership() to not write to the original frame's f_executable
(cherry picked from commit 5bb3bbb)

Co-authored-by: Sam Gross <[email protected]>
@bedevere-app

bedevere-app Bot commented Feb 6, 2026

Copy link
Copy Markdown

GH-144546 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Feb 6, 2026
colesbury added a commit that referenced this pull request Feb 6, 2026
@miss-islington @colesbury
[3.14] gh-144446: Fix some frame object thread-safety issues (gh-144479…
6006005
…) (#144546)

Fix thread-safety issues when accessing frame attributes while another
thread is executing the frame:

- Add critical section to frame_repr() to prevent races when accessing
  the frame's code object and line number

- Add _Py_NO_SANITIZE_THREAD to PyUnstable_InterpreterFrame_GetLasti()
  to allow intentional racy reads of instr_ptr.

- Fix take_ownership() to not write to the original frame's f_executable
(cherry picked from commit 5bb3bbb)

Co-authored-by: Sam Gross <[email protected]>
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
@colesbury @thunder-coding
pythongh-144446: Fix some frame object thread-safety issues (pythongh…
5f30178
…-144479)

Fix thread-safety issues when accessing frame attributes while another
thread is executing the frame:

- Add critical section to frame_repr() to prevent races when accessing
  the frame's code object and line number

- Add _Py_NO_SANITIZE_THREAD to PyUnstable_InterpreterFrame_GetLasti()
  to allow intentional racy reads of instr_ptr.

- Fix take_ownership() to not write to the original frame's f_executable
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@colesbury @ljfp
pythongh-144446: Fix some frame object thread-safety issues (pythongh…
773fb83
…-144479)

Fix thread-safety issues when accessing frame attributes while another
thread is executing the frame:

- Add critical section to frame_repr() to prevent races when accessing
  the frame's code object and line number

- Add _Py_NO_SANITIZE_THREAD to PyUnstable_InterpreterFrame_GetLasti()
  to allow intentional racy reads of instr_ptr.

- Fix take_ownership() to not write to the original frame's f_executable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sergey-miryanov sergey-miryanov sergey-miryanov left review comments
@mpage mpage mpage approved these changes
@kumaraditya303 kumaraditya303 kumaraditya303 approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

topic-free-threading

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@colesbury @sergey-miryanov @mpage @kumaraditya303
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.