Commit 16da1f51bab for php.net

commit 16da1f51bab2c1764d87ac7d891c0cc10e491da5
Author: Florian Engelhardt <florian.engelhardt@datadoghq.com>
Date:   Fri Jul 24 20:07:06 2026 +0200

    Rather than erroring, disable JIT when pthread protection is unavailable (GH-22853)

diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c
index cb2791fb45a..6533f00ede6 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 52be177b915..2e23016f899 100644
--- a/ext/opcache/tests/jit/gh14267_001.phpt
+++ b/ext/opcache/tests/jit/gh14267_001.phpt
@@ -9,7 +9,10 @@
 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 c93b06fda8c..e90fb53e21a 100644
--- a/ext/opcache/tests/jit/gh16393.phpt
+++ b/ext/opcache/tests/jit/gh16393.phpt
@@ -7,7 +7,10 @@
 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 @@ class Test {
 $appendProp2();
 ?>
 --EXPECTF--
-Warning: Undefined variable $test in %sgh16393.php on line 6
+Warning: Undefined variable $test in %sgh16393.php on line 9