Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-128421: Avoid TSAN warnings in sys._current_frames() #131548

Merged
merged 1 commit into from
Mar 24, 2025

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented Mar 21, 2025

This tells TSAN not to sanitize PyUnstable_InterpreterFrame_GetLine(). There's a possible data race on the access to the frame's instr_ptr if the frame is currently executing. We don't really care about the race. In theory, we could use relaxed atomics for every access to instr_ptr, but that would create more code churn and current compilers are overly conservative with optimizations around relaxed atomic accesses.

We also don't sanitize _PyFrame_IsIncomplete() because it accesses instr_ptr and is called from assertions within PyFrame_GetCode().

This tells TSAN not to sanitize PyUnstable_InterpreterFrame_GetLine().
There's a possible data race on the access to the frame's instr_ptr
if the frame is currently executing. We don't really care about the
race. In theory, we could use relaxed atomics for every access to
`instr_ptr`, but that would create more code churn and current compilers
are overly conservative with optimizations around relaxed atomic
accesses.

We also don't sanitize _PyFrame_IsIncomplete() because it accesses
`instr_ptr` and is called from assertions within PyFrame_GetCode().
@colesbury colesbury marked this pull request as ready for review March 21, 2025 17:08
@colesbury colesbury added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 21, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @colesbury for commit 9213b55 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F131548%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 21, 2025
@colesbury colesbury merged commit da6730c into python:main Mar 24, 2025
128 checks passed
@colesbury colesbury deleted the gh-128421-frame-lasti branch March 24, 2025 13:49
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 1, 2025
…ongh-131548)

This tells TSAN not to sanitize `PyUnstable_InterpreterFrame_GetLine()`.
There's a possible data race on the access to the frame's `instr_ptr`
if the frame is currently executing. We don't really care about the
race. In theory, we could use relaxed atomics for every access to
`instr_ptr`, but that would create more code churn and current compilers
are overly conservative with optimizations around relaxed atomic
accesses.

We also don't sanitize `_PyFrame_IsIncomplete()` because it accesses
`instr_ptr` and is called from assertions within PyFrame_GetCode().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants