[php-src] master: Rather than erroring, disable JIT when pthread protection is unavailable (GH-22853)

From: Date: Fri, 24 Jul 2026 18:07:08 +0000
Subject: [php-src] master: Rather than erroring, disable JIT when pthread protection is unavailable (GH-22853)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140208@lists.php.net to get a copy of this message
Author: Florian Engelhardt (realFlowControl) Committer: GitHub (web-flow) Pusher: iluuu1994 Date: 2026-07-24T20:07:06+02:00 Commit: https://github.com/php/php-src/commit/16da1f51bab2c1764d87ac7d891c0cc10e491da5 Raw diff: https://github.com/php/php-src/commit/16da1f51bab2c1764d87ac7d891c0cc10e491da5.diff Rather than erroring, disable JIT when pthread protection is unavailable (GH-22853) Changed paths: M ext/opcache/jit/zend_jit.c M ext/opcache/tests/jit/gh14267_001.phpt M ext/opcache/tests/jit/gh16393.phpt Diff: diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index cb2791fb45ac..6533f00ede6e 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -3724,6 +3724,16 @@ int zend_jit_check_support(void) { int i; +#ifdef ZEND_JIT_USE_APPLE_MAP_JIT + if (!pthread_jit_write_protect_supported_np()) { + zend_accel_error(ACCEL_LOG_WARNING, + "Apple Silicon ZTS JIT requires pthread_jit_write_protect_np() support. JIT disabled."); + JIT_G(enabled) = 0; + JIT_G(on) = 0; + return FAILURE; + } +#endif + if (zend_execute_ex != execute_ex) { if (zend_dtrace_enabled) { zend_error(E_WARNING, "JIT is incompatible with DTrace. JIT disabled."); @@ -3792,11 +3802,6 @@ void zend_jit_startup(void *buf, size_t size, bool reattached) "Unable to share JIT buffer across fork using minherit(): %s (%d)", strerror(error), error); } - if (!pthread_jit_write_protect_supported_np()) { - munmap(buf, size); - zend_accel_error_noreturn(ACCEL_LOG_FATAL, - "Apple Silicon ZTS JIT requires pthread_jit_write_protect_np() support"); - } #endif dasm_buf = buf; diff --git a/ext/opcache/tests/jit/gh14267_001.phpt b/ext/opcache/tests/jit/gh14267_001.phpt index 52be177b9155..2e23016f899b 100644 --- a/ext/opcache/tests/jit/gh14267_001.phpt +++ b/ext/opcache/tests/jit/gh14267_001.phpt @@ -9,7 +9,10 @@ opcache.jit_buffer_size=32M opcache --FILE-- <?php -ini_set('opcache.jit', 'tracing'); +// Skip when JIT was completely disabled at runtime. +if (($status = opcache_get_status()) === false || $status['jit']['enabled']) { + ini_set('opcache.jit', 'tracing'); +} ?> ===DONE=== --EXPECT-- diff --git a/ext/opcache/tests/jit/gh16393.phpt b/ext/opcache/tests/jit/gh16393.phpt index c93b06fda8ce..e90fb53e21a2 100644 --- a/ext/opcache/tests/jit/gh16393.phpt +++ b/ext/opcache/tests/jit/gh16393.phpt @@ -7,7 +7,10 @@ opcache.jit=1215 opcache.jit_buffer_size=64M --FILE-- <?php -ini_set('opcache.jit', 'tracing'); +// Skip when JIT was completely disabled at runtime. +if (($status = opcache_get_status()) === false || $status['jit']['enabled']) { + ini_set('opcache.jit', 'tracing'); +} class Test { } $appendProp2 = (function() { @@ -15,4 +18,4 @@ $appendProp2 = (function() { $appendProp2(); ?> --EXPECTF-- -Warning: Undefined variable $test in %sgh16393.php on line 6 +Warning: Undefined variable $test in %sgh16393.php on line 9

« previous php.cvs (#140208) next »