Commit 5af1b8ef92c for php

commit 5af1b8ef92c7bcfb46e4b97bb4dee0eba813d66a
Merge: dfcf74dff85 51761e7fff9
Author: Arnaud Le Blanc <arnaud.lb@gmail.com>
Date:   Tue Dec 1 12:13:54 2026 +0100

    Merge branch 'PHP-8.6'

    * PHP-8.6:
      Fix GH-24319: Make OPcache hash entry publication and indirection atomic (#25258)

diff --cc ext/opcache/zend_accelerator_hash.h
index 6091361a68c,c4f8d897e67..4038c75b20e
--- a/ext/opcache/zend_accelerator_hash.h
+++ b/ext/opcache/zend_accelerator_hash.h
@@@ -45,13 -47,64 +46,64 @@@ typedef struct _zend_accel_hash_entry z
  struct _zend_accel_hash_entry {
  	zend_ulong             hash_value;
  	zend_string           *key;
+ 	/* Immutable after the entry is published, until zend_accel_hash_clean()
+ 	 * reuses all entries during an OPcache restart (when no readers remain). */
  	zend_accel_hash_entry *next;
- 	void                  *data;
- 	bool                   indirect;
+ 	/* Tagged pointer: bit 0 selects an indirect entry; otherwise a script. */
 -	uintptr_t              data;
++	atomic_uintptr_t       data;
  };

+ #define ZEND_ACCEL_HASH_INDIRECT ((uintptr_t) 1)
+
 -static zend_always_inline zend_accel_hash_entry *zend_accel_hash_load_entry(const uintptr_t *ptr)
++static zend_always_inline zend_accel_hash_entry *zend_accel_hash_load_entry(const atomic_uintptr_t *ptr)
+ {
 -	return (zend_accel_hash_entry *)zend_atomic_load_acquire_uintptr(ptr);
++	return (zend_accel_hash_entry *)atomic_load_explicit(ptr, memory_order_acquire);
+ }
+
 -static zend_always_inline void zend_accel_hash_store_entry(uintptr_t *ptr, zend_accel_hash_entry *value)
++static zend_always_inline void zend_accel_hash_store_entry(atomic_uintptr_t *ptr, zend_accel_hash_entry *value)
+ {
 -	zend_atomic_store_release_uintptr(ptr, (uintptr_t)value);
++	atomic_store_explicit(ptr, (uintptr_t)value, memory_order_release);
+ }
+
+ static zend_always_inline uintptr_t zend_accel_hash_load_data(const zend_accel_hash_entry *entry)
+ {
 -	return zend_atomic_load_acquire_uintptr(&entry->data);
++	return atomic_load_explicit(&entry->data, memory_order_acquire);
+ }
+
+ static zend_always_inline void zend_accel_hash_store_data(zend_accel_hash_entry *entry, uintptr_t value)
+ {
 -	zend_atomic_store_release_uintptr(&entry->data, value);
++	atomic_store_explicit(&entry->data, value, memory_order_release);
+ }
+
+ static zend_always_inline zend_accel_hash_entry *zend_accel_hash_indirect_target(uintptr_t data)
+ {
+ 	ZEND_ASSERT(data & ZEND_ACCEL_HASH_INDIRECT);
+ 	return (zend_accel_hash_entry *)(data & ~ZEND_ACCEL_HASH_INDIRECT);
+ }
+
+ /* An entry returned by find_entry() can become indirect before the caller
+  * uses it. Resolve each atomically loaded value, including newly formed chains. */
+ static zend_always_inline void *zend_accel_hash_entry_data(const zend_accel_hash_entry *entry)
+ {
+ 	while (1) {
+ 		uintptr_t data = zend_accel_hash_load_data(entry);
+ 		if (!(data & ZEND_ACCEL_HASH_INDIRECT)) {
+ 			return (void *)data;
+ 		}
+ 		entry = zend_accel_hash_indirect_target(data);
+ 	}
+ }
+
+ /* Enumerators need the kind and data from the same snapshot. */
+ static zend_always_inline void *zend_accel_hash_direct_data(const zend_accel_hash_entry *entry)
+ {
+ 	uintptr_t data = zend_accel_hash_load_data(entry);
+ 	return (data & ZEND_ACCEL_HASH_INDIRECT) ? NULL : (void *)data;
+ }
+
  typedef struct _zend_accel_hash {
- 	zend_accel_hash_entry **hash_table;
+ 	/* Bucket heads are untagged entry addresses. */
 -	uintptr_t             *hash_table;
++	atomic_uintptr_t       *hash_table;
  	zend_accel_hash_entry  *hash_entries;
  	uint32_t               num_entries;
  	uint32_t               max_num_entries;