Skip to content

Commit 443fc76

Browse files
fix deinstrumentation
1 parent e41c1ce commit 443fc76

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Python/instrumentation.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,9 +1190,10 @@ call_instrumentation_vector(
11901190
break;
11911191
}
11921192
else {
1193-
LOCK_CODE(code);
1193+
PyInterpreterState *interp = tstate->interp;
1194+
_PyEval_StopTheWorld(interp);
11941195
remove_tools(code, offset, event, 1 << tool);
1195-
UNLOCK_CODE();
1196+
_PyEval_StartTheWorld(interp);
11961197
}
11971198
}
11981199
}
@@ -1381,9 +1382,10 @@ _Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame,
13811382
}
13821383
else {
13831384
/* DISABLE */
1384-
LOCK_CODE(code);
1385+
PyInterpreterState *interp = tstate->interp;
1386+
_PyEval_StopTheWorld(interp);
13851387
remove_line_tools(code, i, 1 << tool);
1386-
UNLOCK_CODE();
1388+
_PyEval_StartTheWorld(interp);
13871389
}
13881390
} while (tools);
13891391
Py_DECREF(line_obj);
@@ -1438,9 +1440,10 @@ _Py_call_instrumentation_instruction(PyThreadState *tstate, _PyInterpreterFrame*
14381440
}
14391441
else {
14401442
/* DISABLE */
1441-
LOCK_CODE(code);
1443+
PyInterpreterState *interp = tstate->interp;
1444+
_PyEval_StopTheWorld(interp);
14421445
remove_per_instruction_tools(code, offset, 1 << tool);
1443-
UNLOCK_CODE();
1446+
_PyEval_StartTheWorld(interp);
14441447
}
14451448
}
14461449
Py_DECREF(offset_obj);
@@ -2995,9 +2998,10 @@ branch_handler_vectorcall(
29952998
// Orphaned NOT_TAKEN -- Jump removed by the compiler
29962999
return res;
29973000
}
2998-
LOCK_CODE(code);
3001+
PyInterpreterState *interp = _PyInterpreterState_GET();
3002+
_PyEval_StopTheWorld(interp);
29993003
remove_tools(code, offset, other_event, 1 << self->tool_id);
3000-
UNLOCK_CODE();
3004+
_PyEval_StartTheWorld(interp);
30013005
}
30023006
return res;
30033007
}

0 commit comments

Comments
 (0)