]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-128421: Avoid TSAN warnings in `sys._current_frames()` (gh-131548)
authorSam Gross <colesbury@gmail.com>
Mon, 24 Mar 2025 13:49:39 +0000 (09:49 -0400)
committerGitHub <noreply@github.com>
Mon, 24 Mar 2025 13:49:39 +0000 (09:49 -0400)
commitda6730caa5023bd351a3f2a1b64b174c8e609489
tree3b4fcc8b1a4a2021721c09cba93c71b3c18b6955
parent4596666a9f9f6b97085619553a5cecb84ff6486d
gh-128421: Avoid TSAN warnings in `sys._current_frames()` (gh-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().
Include/internal/pycore_interpframe.h
Include/pyport.h
Objects/obmalloc.c
Python/frame.c