Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-128421: Add locking to most frame object functions#131479

Merged
colesbury merged 6 commits intopython:mainfrom
colesbury:gh-128421-frame
Mar 21, 2025
Merged

gh-128421: Add locking to most frame object functions#131479
colesbury merged 6 commits intopython:mainfrom
colesbury:gh-128421-frame

Conversation

@colesbury
Copy link
Contributor

@colesburycolesbury commentedMar 19, 2025
edited by bedevere-appbot
Loading

This makes more operations on frame objects thread-safe in the free threaded build, which fixes some data races that occurred when passing exceptions between threads.

However, accessing local variables or the line number of a frame from another thread while its still executing is not thread-safe and may crash the interpreter.

This makes more operations on frame objects thread-safe in the freethreaded build, which fixes some data races that occurred when passingexceptions between threads.However, accessing local variables from another thread while its runningis still not thread-safe and may crash the interpreter.
@colesbury
Copy link
ContributorAuthor

I added the additional critical sections, although I'm pretty ambivalent about having them in the C APIs.

Copy link
Contributor

@kumaraditya303kumaraditya303 left a comment

Choose a reason for hiding this comment

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

LGTM

@colesburycolesbury merged commit4f32516 intopython:mainMar 21, 2025
45 checks passed
@colesburycolesbury deleted the gh-128421-frame branchMarch 21, 2025 15:10
colesbury added a commit to colesbury/cpython that referenced this pull requestMar 25, 2025
The recent PRpythongh-131479 added locking to `take_ownership` in the freethreading build. The cost is not really the locking -- that path isn'ttaken frequently -- but the inlined code causes extra register spillsand slows down RETURN_VALUE, even when it's not taken.Mark `take_ownership` as `Py_NO_INLINE` to avoid the regression.
colesbury added a commit to colesbury/cpython that referenced this pull requestMar 25, 2025
The recent PRpythongh-131479 added locking to `take_ownership` in the freethreading build. The cost is not really the locking -- that path isn'ttaken frequently -- but the inlined code causes extra register spillsand slows down RETURN_VALUE, even when it's not taken.Mark `take_ownership` as `Py_NO_INLINE` to avoid the regression.Also limit locking in PyFrameObject to Python functions, not the C API.
colesbury added a commit to colesbury/cpython that referenced this pull requestMar 27, 2025
The recent PRpythongh-131479 added locking to `take_ownership` in the freethreading build. The cost is not really the locking -- that path isn'ttaken frequently -- but the inlined code causes extra register spillsand slows down RETURN_VALUE, even when it's not taken.Mark `take_ownership` as `Py_NO_INLINE` to avoid the regression.Also limit locking in PyFrameObject to Python functions, not the C API.PyFrame_GetCode is called frequently by coverage and tracing tools.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@kumaraditya303kumaraditya303kumaraditya303 approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@colesbury@kumaraditya303

[8]ページ先頭

©2009-2026 Movatter.jp