Commit 82c00950e19 for php
commit 82c00950e195c9938dcd2015aecccec9ef84b094
Author: Ilia Alshanetsky <ilia@ilia.ws>
Date: Fri Dec 4 12:09:49 2026 -0500
Zend: Check vm_interrupt with relaxed load before atomic exchange (#25976)
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.
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index a56bc53725b..57c245a64c2 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()) {