mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
[3.13] gh-131141: fix data race in instrumentation while registering callback (#131166)
This commit is contained in:
parent
589f422d1b
commit
589382bd04
2 changed files with 5 additions and 3 deletions
|
@ -0,0 +1 @@
|
|||
Fix data race in :data:`sys.monitoring` instrumentation while registering callback.
|
|
@ -1399,9 +1399,10 @@ _PyMonitoring_RegisterCallback(int tool_id, int event_id, PyObject *obj)
|
|||
PyInterpreterState *is = _PyInterpreterState_GET();
|
||||
assert(0 <= tool_id && tool_id < PY_MONITORING_TOOL_IDS);
|
||||
assert(0 <= event_id && event_id < _PY_MONITORING_EVENTS);
|
||||
PyObject *callback = _Py_atomic_exchange_ptr(&is->monitoring_callables[tool_id][event_id],
|
||||
Py_XNewRef(obj));
|
||||
|
||||
_PyEval_StopTheWorld(is);
|
||||
PyObject *callback = is->monitoring_callables[tool_id][event_id];
|
||||
is->monitoring_callables[tool_id][event_id] = Py_XNewRef(obj);
|
||||
_PyEval_StartTheWorld(is);
|
||||
return callback;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue