[php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5
| From: | David Carlier | Date: | Mon, 28 Sep 2026 14:19:24 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141628@lists.php.net to get a copy of this message | ||
Author: David Carlier (devnexen)
Date: 2026-09-28T15:18:40+01:00
Commit: https://github.com/php/php-src/commit/9a11b35a16fd243b41c07064cfb169a0c6f17187
Raw diff: https://github.com/php/php-src/commit/9a11b35a16fd243b41c07064cfb169a0c6f17187.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
Fix GH-23637: opcache inheritance cache entry published too early
Changed paths:
M Zend/zend_atomic.h
M ext/opcache/ZendAccelerator.c
Diff:
diff --git a/Zend/zend_atomic.h b/Zend/zend_atomic.h
index 56422a721fdb..5eeb212ec09e 100644
--- a/Zend/zend_atomic.h
+++ b/Zend/zend_atomic.h
@@ -385,6 +385,23 @@ ZEND_API bool zend_atomic_bool_load(const zend_atomic_bool *obj);
ZEND_API int zend_atomic_int_load(const zend_atomic_int *obj);
#endif
+#if defined(HAVE_C11_ATOMICS)
+# define ZEND_ATOMIC_FENCE_RELEASE() __c11_atomic_thread_fence(__ATOMIC_RELEASE)
+# define ZEND_ATOMIC_FENCE_ACQUIRE() __c11_atomic_thread_fence(__ATOMIC_ACQUIRE)
+#elif defined(HAVE_GNUC_ATOMICS)
+# define ZEND_ATOMIC_FENCE_RELEASE() __atomic_thread_fence(__ATOMIC_RELEASE)
+# define ZEND_ATOMIC_FENCE_ACQUIRE() __atomic_thread_fence(__ATOMIC_ACQUIRE)
+#elif defined(HAVE_SYNC_ATOMICS)
+# define ZEND_ATOMIC_FENCE_RELEASE() __sync_synchronize()
+# define ZEND_ATOMIC_FENCE_ACQUIRE() __sync_synchronize()
+#elif defined(ZEND_WIN32)
+# define ZEND_ATOMIC_FENCE_RELEASE() MemoryBarrier()
+# define ZEND_ATOMIC_FENCE_ACQUIRE() MemoryBarrier()
+#else
+# define ZEND_ATOMIC_FENCE_RELEASE() ((void)0)
+# define ZEND_ATOMIC_FENCE_ACQUIRE() ((void)0)
+#endif
+
END_EXTERN_C()
#endif
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 951d042767d1..4a543999bee8 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -2322,6 +2322,10 @@ static zend_class_entry* zend_accel_inheritance_cache_get(zend_class_entry
*ce,
bool needs_autoload;
zend_inheritance_cache_entry *entry = ce->inheritance_cache;
+ if (entry) {
+ ZEND_ATOMIC_FENCE_ACQUIRE();
+ }
+
while (entry) {
entry = zend_accel_inheritance_cache_find(entry, ce, parent, traits_and_interfaces,
&needs_autoload);
if (entry) {
@@ -2478,9 +2482,10 @@ static zend_class_entry* zend_accel_inheritance_cache_add(zend_class_entry
*ce,
entry->num_warnings = EG(num_errors);
entry->warnings = zend_persist_warnings(EG(num_errors), EG(errors));
entry->next = proto->inheritance_cache;
- proto->inheritance_cache = entry;
ZCSG(map_ptr_last) = CG(map_ptr_last);
+ ZEND_ATOMIC_FENCE_RELEASE();
+ proto->inheritance_cache = entry;
zend_shared_alloc_destroy_xlat_table();