mirror of
https://github.com/python/cpython.git
synced 2025-12-31 12:33:28 +00:00
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().
This commit is contained in:
parent
4596666a9f
commit
da6730caa5
4 changed files with 25 additions and 36 deletions
|
|
@ -139,7 +139,9 @@ PyUnstable_InterpreterFrame_GetLasti(struct _PyInterpreterFrame *frame)
|
|||
return _PyInterpreterFrame_LASTI(frame) * sizeof(_Py_CODEUNIT);
|
||||
}
|
||||
|
||||
int
|
||||
// NOTE: We allow racy accesses to the instruction pointer from other threads
|
||||
// for sys._current_frames() and similar APIs.
|
||||
int _Py_NO_SANITIZE_THREAD
|
||||
PyUnstable_InterpreterFrame_GetLine(_PyInterpreterFrame *frame)
|
||||
{
|
||||
int addr = _PyInterpreterFrame_LASTI(frame) * sizeof(_Py_CODEUNIT);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue