Commit 03c5ad7ad68 for php

commit 03c5ad7ad6802b0079074b7a1c5665f9e3d592c7
Author: Arnaud Le Blanc <365207+arnaud-lb@users.noreply.github.com>
Date:   Fri Oct 16 19:21:41 2026 +0200

    JIT: Fix TLS access with SHM reattachment (#24355)

    Different processes may load modules in a different order, so TLS variables may have different offsets. This is an issue when JIT hard-codes those offsets into generated code that may be executed by other processes.

    Fix by not resolving the TLS offsets when ZEND_OPCACHE_SHM_REATTACHMENT is defined, so that generated code falls back to runtime resolution.

    Co-Authored-By: ndossche <7771979+ndossche@users.noreply.github.com>

diff --git a/NEWS b/NEWS
index 3b782b201dd..03e260b79e1 100644
--- a/NEWS
+++ b/NEWS
@@ -60,6 +60,8 @@ PHP                                                                        NEWS
     in closures). (RV7PR)
   . Fixed bug GH-24337 (JIT: segfault when decrementing a non-numeric string
     property). (Lazizbek Ergashev)
+  . Fixed bug GH-24185 (Windows ZTS: random access violations with OPcache JIT
+    in multi-process setups). (Arnaud, ndossche)

 - PDO:
   . Fixed a duplicate warning when ATTR_STATEMENT_CLASS is rejected on a
diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c
index 7423a22b709..0bad8e1605b 100644
--- a/ext/opcache/jit/zend_jit_ir.c
+++ b/ext/opcache/jit/zend_jit_ir.c
@@ -3412,6 +3412,10 @@ static void zend_jit_setup(bool reattached)
 #endif

 #ifdef ZTS
+# ifdef ZEND_OPCACHE_SHM_REATTACHMENT
+	/* Different processes may load TLS variables in a different order, so we
+	 * can not rely on offsets. We will fallback to runtime resolution. */
+# else
 	zend_result result = zend_jit_resolve_tsrm_ls_cache_offsets(
 		&tsrm_ls_cache_tcb_offset,
 		&tsrm_tls_index,
@@ -3421,6 +3425,7 @@ static void zend_jit_setup(bool reattached)
 		zend_accel_error(ACCEL_LOG_INFO,
 				"Could not get _tsrm_ls_cache offsets, will fallback to runtime resolution");
 	}
+# endif
 #endif

 #if !defined(ZEND_WIN32) && !defined(IR_TARGET_AARCH64)