]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117657: Fix some simple races in instrumentation.c (GH-120118)
authorKen Jin <kenjin@python.org>
Thu, 13 Jun 2024 09:31:21 +0000 (17:31 +0800)
committerGitHub <noreply@github.com>
Thu, 13 Jun 2024 09:31:21 +0000 (17:31 +0800)
* stop the world when setting local events

Python/instrumentation.c

index a5211ee5428cf805b3531a249941993619cc5633..ae790a1441b9339ad77e96893e7334e2db86bef9 100644 (file)
@@ -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;
 }