From: Ken Jin Date: Thu, 13 Jun 2024 09:31:21 +0000 (+0800) Subject: gh-117657: Fix some simple races in instrumentation.c (GH-120118) X-Git-Tag: v3.14.0a1~1510 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b1b61dc4cee43920ef2b08d5ac94ddf08119c507;p=thirdparty%2FPython%2Fcpython.git gh-117657: Fix some simple races in instrumentation.c (GH-120118) * stop the world when setting local events --- diff --git a/Python/instrumentation.c b/Python/instrumentation.c index a5211ee5428c..ae790a1441b9 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -1977,7 +1977,7 @@ _PyMonitoring_SetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEvent } int res; - LOCK_CODE(code); + _PyEval_StopTheWorld(interp); if (allocate_instrumentation_data(code)) { res = -1; goto done; @@ -1994,7 +1994,7 @@ _PyMonitoring_SetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEvent res = force_instrument_lock_held(code, interp); done: - UNLOCK_CODE(); + _PyEval_StartTheWorld(interp); return res; }