Skip to content

Commit fa40c72

Browse files
Fix some simple races in instrumentation.c
1 parent 10eac02 commit fa40c72

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Python/instrumentation.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ de_instrument_per_instruction(PyCodeObject *code, int i)
666666
int original_opcode = code->_co_monitoring->per_instruction_opcodes[i];
667667
CHECK(original_opcode != 0);
668668
CHECK(original_opcode == _PyOpcode_Deopt[original_opcode]);
669-
*opcode_ptr = original_opcode;
669+
FT_ATOMIC_STORE_UINT8_RELAXED(*opcode_ptr, original_opcode);
670670
if (_PyOpcode_Caches[original_opcode]) {
671671
instr[1].counter = adaptive_counter_warmup();
672672
}
@@ -717,7 +717,7 @@ instrument_line(PyCodeObject *code, int i)
717717
_PyCoLineInstrumentationData *lines = &code->_co_monitoring->lines[i];
718718
lines->original_opcode = _PyOpcode_Deopt[opcode];
719719
CHECK(lines->original_opcode > 0);
720-
*opcode_ptr = INSTRUMENTED_LINE;
720+
FT_ATOMIC_STORE_UINT8_RELAXED(*opcode_ptr, INSTRUMENTED_LINE);
721721
}
722722

723723
static void
@@ -746,7 +746,7 @@ instrument_per_instruction(PyCodeObject *code, int i)
746746
code->_co_monitoring->per_instruction_opcodes[i] = _PyOpcode_Deopt[opcode];
747747
}
748748
assert(code->_co_monitoring->per_instruction_opcodes[i] > 0);
749-
*opcode_ptr = INSTRUMENTED_INSTRUCTION;
749+
FT_ATOMIC_STORE_UINT8_RELAXED(*opcode_ptr, INSTRUMENTED_INSTRUCTION);
750750
}
751751

752752
static void

0 commit comments

Comments
 (0)