From da5982ce5d745f7f0dddfa8f394527f3cfe722e9 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Fri, 27 Nov 2026 07:24:08 -0500 Subject: [PATCH] Zend: Check vm_interrupt with relaxed load before atomic exchange zend_call_function() executed an atomic_exchange() on EG(vm_interrupt) on every internal-to-PHP callback return, an exclusive cache-line read-modify-write even when no interrupt is pending. Load the flag first and exchange only when it is set, as ZEND_VM_FCALL_INTERRUPT_CHECK() does. A relaxed load suffices: a stale false only defers handling to the next VM interrupt check, and the exchange stays the synchronizing operation. --- Zend/zend_execute_API.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index a56bc53725bd..57c245a64c27 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1120,7 +1120,8 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_ } } - if (UNEXPECTED(atomic_exchange(&EG(vm_interrupt), false))) { + if (UNEXPECTED(atomic_load_explicit(&EG(vm_interrupt), memory_order_relaxed)) + && EXPECTED(atomic_exchange(&EG(vm_interrupt), false))) { if (atomic_load(&EG(timed_out))) { zend_timeout(); } else if (ZEND_HAS_OOM()) {