Skip to content

Commit

Permalink
Fix data race in _PyInstruction_GetLength
Browse files Browse the repository at this point in the history
Read the opcode atomically, the interpreter may be specializing it
  • Loading branch information
mpage committed Sep 10, 2024
1 parent 81fe1a2 commit 837645e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Python/instrumentation.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ _PyInstruction_GetLength(PyCodeObject *code, int offset)
{
ASSERT_WORLD_STOPPED_OR_LOCKED(code);

int opcode = _PyCode_CODE(code)[offset].op.code;
int opcode =
FT_ATOMIC_LOAD_UINT8_RELAXED(_PyCode_CODE(code)[offset].op.code);
assert(opcode != 0);
assert(opcode != RESERVED);
if (opcode == INSTRUMENTED_LINE) {
Expand Down

0 comments on commit 837645e

Please sign in to comment.