[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Ilia Alshanetsky | Date: | Mon, 19 Oct 2026 17:43:45 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142461@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-10-19T13:31:39-04:00
Commit: https://github.com/php/php-src/commit/f0798b516473977a25a512d072f76b1f3c64db7a
Raw diff: https://github.com/php/php-src/commit/f0798b516473977a25a512d072f76b1f3c64db7a.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
ext/opcache: Mark dl()-created persistent strings as thread-local
Changed paths:
A ext/dl_test/tests/opcache_temporary_strings.inc
A ext/dl_test/tests/opcache_temporary_strings.phpt
M ext/dl_test/dl_test.stub.php
M ext/dl_test/dl_test_arginfo.h
M ext/opcache/ZendAccelerator.c
Diff:
diff --git a/ext/dl_test/dl_test.stub.php b/ext/dl_test/dl_test.stub.php
index ad2de67fb6de..4854f86485dd 100644
--- a/ext/dl_test/dl_test.stub.php
+++ b/ext/dl_test/dl_test.stub.php
@@ -22,6 +22,7 @@ public function test(string $str = ""): string {}
class DlTestSuperClass {
public int $a;
+ public int $temporary = 0;
public function test(string $str = ""): string {}
}
diff --git a/ext/dl_test/dl_test_arginfo.h b/ext/dl_test/dl_test_arginfo.h
index f659696e4e7c..d9d1c91682fd 100644
--- a/ext/dl_test/dl_test_arginfo.h
+++ b/ext/dl_test/dl_test_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit dl_test.stub.php instead.
- * Stub hash: f935fbfb32fd8d960437269566d6bcaa3be7b6b0 */
+ * Stub hash: 6f3b106c9f5e6d4b0a69451827c10ad6dad0d8f7 */
#include "zend_constants.h"
@@ -76,6 +76,12 @@ static zend_class_entry *register_class_DlTestSuperClass(void)
zend_declare_typed_property(class_entry, property_a_name, &property_a_default_value,
ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release_ex(property_a_name, true);
+ zval property_temporary_default_value;
+ ZVAL_LONG(&property_temporary_default_value, 0);
+ zend_string *property_temporary_name = zend_string_init("temporary",
sizeof("temporary") - 1, true);
+ zend_declare_typed_property(class_entry, property_temporary_name,
&property_temporary_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type)
ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+ zend_string_release_ex(property_temporary_name, true);
+
return class_entry;
}
diff --git a/ext/dl_test/tests/opcache_temporary_strings.inc
b/ext/dl_test/tests/opcache_temporary_strings.inc
new file mode 100644
index 000000000000..2da8426961cd
--- /dev/null
+++ b/ext/dl_test/tests/opcache_temporary_strings.inc
@@ -0,0 +1,16 @@
+<?php
+try {
+ dl_test_test2([]);
+} catch (TypeError $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+}
+
+try {
+ (new DlTest)->test([]);
+} catch (TypeError $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+}
+
+var_dump((new ReflectionFunction('dl_test_test2'))->getName());
+
+var_dump(get_object_vars(new DlTestSubClass));
diff --git a/ext/dl_test/tests/opcache_temporary_strings.phpt
b/ext/dl_test/tests/opcache_temporary_strings.phpt
new file mode 100644
index 000000000000..e51a2b7247ca
--- /dev/null
+++ b/ext/dl_test/tests/opcache_temporary_strings.phpt
@@ -0,0 +1,22 @@
+--TEST--
+dl() under opcache: refcounting names declared by a temporary module
+--SKIPIF--
+<?php include __DIR__ . "/skip.inc"; ?>
+--EXTENSIONS--
+opcache
+--INI--
+enable_dl=1
+opcache.enable_cli=1
+--FILE--
+<?php
+dl(PHP_OS_FAMILY === 'Windows' ? 'php_dl_test.dll' : 'dl_test.so');
+include __DIR__ . '/opcache_temporary_strings.inc';
+?>
+--EXPECT--
+TypeError: dl_test_test2(): Argument #1 ($str) must be of type string, array given
+TypeError: DlTest::test(): Argument #1 ($str) must be of type string, array given
+string(13) "dl_test_test2"
+array(1) {
+ ["temporary"]=>
+ int(0)
+}
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index da852f0ce79a..2ea020c8949c 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -585,6 +585,13 @@ static zend_string* ZEND_FASTCALL accel_new_interned_string_for_php(zend_string
return ret;
}
}
+#if ZEND_RC_DEBUG
+ /* PHP shouldn't create persistent strings during request, but at least
+ * dl() may do this. They belong to the temporary module and are not shared. */
+ if (!zend_rc_debug && !ZSTR_IS_INTERNED(str) && (GC_FLAGS(str) &
GC_PERSISTENT)) {
+ GC_MAKE_PERSISTENT_LOCAL(str);
+ }
+#endif
return str;
}
@@ -608,19 +615,31 @@ static zend_always_inline zend_string
*accel_find_interned_string_ex(zend_ulong
static zend_string* ZEND_FASTCALL accel_init_interned_string_for_php(const char *str, size_t size,
bool permanent)
{
+ zend_string *ret;
+
if (ZCG(counted)) {
zend_ulong h = zend_inline_hash_func(str, size);
- zend_string *ret = accel_find_interned_string_ex(h, str, size);
+ ret = accel_find_interned_string_ex(h, str, size);
- if (!ret) {
- ret = zend_string_init(str, size, permanent);
- ZSTR_H(ret) = h;
+ if (ret) {
+ return ret;
}
- return ret;
+ ret = zend_string_init(str, size, permanent);
+ ZSTR_H(ret) = h;
+ } else {
+ ret = zend_string_init(str, size, permanent);
}
- return zend_string_init(str, size, permanent);
+#if ZEND_RC_DEBUG
+ /* PHP shouldn't create persistent strings during request, but at least
+ * dl() may do this. They belong to the temporary module and are not shared. */
+ if (!zend_rc_debug && permanent) {
+ GC_MAKE_PERSISTENT_LOCAL(ret);
+ }
+#endif
+
+ return ret;
}
static inline void accel_copy_permanent_list_types(