From 5e5990e019fe745c202b212bd601c8e09aac0138 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Tue, 21 Jul 2026 21:13:35 +0200 Subject: [PATCH 1/5] Disable JIT when pthread protection is unavailable --- ext/opcache/jit/zend_jit.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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; From 45a90df2e1210e38006d5421439e82fcadf16427 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Wed, 22 Jul 2026 11:54:46 +0200 Subject: [PATCH 2/5] Re-trigger CI From c47777885353b9822e328fe89acbb9f94a18b575 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Wed, 22 Jul 2026 13:26:40 +0200 Subject: [PATCH 3/5] Skip JIT runtime test when JIT is unavailable --- ext/opcache/tests/jit/gh14267_001.phpt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/opcache/tests/jit/gh14267_001.phpt b/ext/opcache/tests/jit/gh14267_001.phpt index 52be177b9155..b22159ba52a0 100644 --- a/ext/opcache/tests/jit/gh14267_001.phpt +++ b/ext/opcache/tests/jit/gh14267_001.phpt @@ -7,6 +7,10 @@ opcache.jit=off opcache.jit_buffer_size=32M --EXTENSIONS-- opcache +--SKIPIF-- + --FILE-- Date: Wed, 22 Jul 2026 14:07:21 +0200 Subject: [PATCH 4/5] Allow JIT disabled warning when unavailable --- ext/opcache/tests/jit/gh14267_001.phpt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ext/opcache/tests/jit/gh14267_001.phpt b/ext/opcache/tests/jit/gh14267_001.phpt index b22159ba52a0..cc914222a4d6 100644 --- a/ext/opcache/tests/jit/gh14267_001.phpt +++ b/ext/opcache/tests/jit/gh14267_001.phpt @@ -7,14 +7,11 @@ opcache.jit=off opcache.jit_buffer_size=32M --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- ===DONE=== ---EXPECT-- -===DONE=== +--EXPECTREGEX-- +^(?:Warning: Cannot change opcache\.jit setting at run-time \(JIT is disabled\) in .+ on line 2 +)?===DONE===$ From dcaf0bd8a36d178893124a68fa2e3888134361f6 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Wed, 22 Jul 2026 15:21:03 +0200 Subject: [PATCH 5/5] Allow JIT fallback warnings in OPcache tests --- ext/opcache/tests/bu69838.phpt | 4 ++-- ext/opcache/tests/bug70423.phpt | 4 ++-- ext/opcache/tests/bug79665.phpt | 2 +- ext/opcache/tests/gh9259_001.phpt | 2 +- ext/opcache/tests/gh9259_002.phpt | 2 +- ext/opcache/tests/jit/gh16393.phpt | 2 +- ext/opcache/tests/preload_user_001.phpt | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/opcache/tests/bu69838.phpt b/ext/opcache/tests/bu69838.phpt index 0f83635dca6a..5a697cdbd44f 100644 --- a/ext/opcache/tests/bu69838.phpt +++ b/ext/opcache/tests/bu69838.phpt @@ -14,5 +14,5 @@ $x = gethostbyname("localhost"); ?> ===DONE=== ---EXPECT-- -===DONE=== +--EXPECTF-- +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%r===DONE=== diff --git a/ext/opcache/tests/bug70423.phpt b/ext/opcache/tests/bug70423.phpt index 6015a46b46d3..f641fa67e0ea 100644 --- a/ext/opcache/tests/bug70423.phpt +++ b/ext/opcache/tests/bug70423.phpt @@ -54,8 +54,8 @@ $fn2(); // 5 $fn1(); // 1 $fn2(); // 6 ?> ---EXPECT-- -1 +--EXPECTF-- +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%r1 1 1 1 diff --git a/ext/opcache/tests/bug79665.phpt b/ext/opcache/tests/bug79665.phpt index 7e101f5a008b..720a88191d52 100644 --- a/ext/opcache/tests/bug79665.phpt +++ b/ext/opcache/tests/bug79665.phpt @@ -24,7 +24,7 @@ var_dump($config['directives']['opcache.max_accelerated_files']); %s: Warning opcache.max_wasted_percentage must be set between 1 and 50. -string(1) "5" +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%rstring(1) "5" float(0.05) string(3) "128" int(134217728) diff --git a/ext/opcache/tests/gh9259_001.phpt b/ext/opcache/tests/gh9259_001.phpt index d98cbfb891d7..1153af6ff93c 100644 --- a/ext/opcache/tests/gh9259_001.phpt +++ b/ext/opcache/tests/gh9259_001.phpt @@ -17,4 +17,4 @@ echo 'OK'; --EXPECTF-- %sWarning opcache.interned_strings_buffer must be less than or equal to 32767, 131072 given%s -OK +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%rOK diff --git a/ext/opcache/tests/gh9259_002.phpt b/ext/opcache/tests/gh9259_002.phpt index 8b74949b4946..911374fe4728 100644 --- a/ext/opcache/tests/gh9259_002.phpt +++ b/ext/opcache/tests/gh9259_002.phpt @@ -15,4 +15,4 @@ echo 'OK'; --EXPECTF-- %sWarning opcache.interned_strings_buffer must be greater than or equal to 0, -1 given%s -OK +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%rOK diff --git a/ext/opcache/tests/jit/gh16393.phpt b/ext/opcache/tests/jit/gh16393.phpt index c93b06fda8ce..e07808ba0e9c 100644 --- a/ext/opcache/tests/jit/gh16393.phpt +++ b/ext/opcache/tests/jit/gh16393.phpt @@ -15,4 +15,4 @@ $appendProp2 = (function() { $appendProp2(); ?> --EXPECTF-- -Warning: Undefined variable $test in %sgh16393.php on line 6 +%r(?:Warning: Cannot change opcache\.jit setting at run-time \(JIT is disabled\) in .*gh16393\.php on line 2\n\n)?%rWarning: Undefined variable $test in %sgh16393.php on line 6 diff --git a/ext/opcache/tests/preload_user_001.phpt b/ext/opcache/tests/preload_user_001.phpt index 2a7cb2955441..35cb09d5547c 100644 --- a/ext/opcache/tests/preload_user_001.phpt +++ b/ext/opcache/tests/preload_user_001.phpt @@ -22,7 +22,7 @@ var_dump(function_exists("f2")); ?> OK --EXPECTF-- -%sWarning "opcache.preload_user" is ignored because the current user is not "root" +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%r%sWarning "opcache.preload_user" is ignored because the current user is not "root" bool(true) bool(false) OK