[php-src] PHP-8.5: JIT: Fix TLS access with SHM reattachment (#24355)

From: Date: Fri, 16 Oct 2026 17:21:45 +0000
Subject: [php-src] PHP-8.5: JIT: Fix TLS access with SHM reattachment (#24355)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142358@lists.php.net to get a copy of this message
Author: Arnaud Le Blanc (arnaud-lb) Committer: GitHub (web-flow) Pusher: arnaud-lb Date: 2026-10-16T19:21:41+02:00 Commit: https://github.com/php/php-src/commit/03c5ad7ad6802b0079074b7a1c5665f9e3d592c7 Raw diff: https://github.com/php/php-src/commit/03c5ad7ad6802b0079074b7a1c5665f9e3d592c7.diff 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> Changed paths: M NEWS M ext/opcache/jit/zend_jit_ir.c Diff: diff --git a/NEWS b/NEWS index 3b782b201dd9..03e260b79e1b 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 7423a22b709c..0bad8e1605b5 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)

« previous php.cvs (#142358) next »