mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-137992: Stop the world when calling PyRefTracer_SetTracer (#137994)
This commit is contained in:
parent
2d724939d7
commit
c5180d74e1
2 changed files with 5 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
Ensure that :c:func:`PyRefTracer_SetTracer` sync with all existing threads when called
|
||||
to avoid races in the free threaded build. Patch by Pablo Galindo
|
||||
|
|
@ -3287,6 +3287,8 @@ _Py_SetRefcnt(PyObject *ob, Py_ssize_t refcnt)
|
|||
|
||||
int PyRefTracer_SetTracer(PyRefTracer tracer, void *data) {
|
||||
_Py_AssertHoldsTstate();
|
||||
|
||||
_PyEval_StopTheWorldAll(&_PyRuntime);
|
||||
if (_PyRuntime.ref_tracer.tracer_func != NULL) {
|
||||
_PyReftracerTrack(NULL, PyRefTracer_TRACKER_REMOVED);
|
||||
if (PyErr_Occurred()) {
|
||||
|
|
@ -3295,6 +3297,7 @@ int PyRefTracer_SetTracer(PyRefTracer tracer, void *data) {
|
|||
}
|
||||
_PyRuntime.ref_tracer.tracer_func = tracer;
|
||||
_PyRuntime.ref_tracer.tracer_data = data;
|
||||
_PyEval_StartTheWorldAll(&_PyRuntime);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue