diff --git a/src/machine/machine_state_impl.rs b/src/machine/machine_state_impl.rs index 0e4a4e1c..5de07140 100644 --- a/src/machine/machine_state_impl.rs +++ b/src/machine/machine_state_impl.rs @@ -3130,9 +3130,14 @@ impl MachineState { ) { let interrupted = INTERRUPT.load(std::sync::atomic::Ordering::Relaxed); - if INTERRUPT.compare_and_swap(interrupted, false, std::sync::atomic::Ordering::Relaxed) { - self.throw_interrupt_exception(); - return; + match INTERRUPT.compare_exchange(interrupted, false, std::sync::atomic::Ordering::Relaxed, std::sync::atomic::Ordering::Relaxed) { + Ok(interruption) => { + if interruption { + self.throw_interrupt_exception(); + return; + } + }, + Err(_) => unreachable!() } let mut default_call_policy: Box = Box::new(DefaultCallPolicy {});