Merge branch 'PHP-8.5' into PHP-8.6

* PHP-8.5:
  ext/opcache: Mark dl()-created persistent strings as thread-local
This commit is contained in:
Ilia Alshanetsky committed 2026-10-19 13:31:39 -04:00
commit f0798b5164
5 files changed
+71 -7

No files matched your search

+1
View File
@@ -22,6 +22,7 @@ class DlTest {
class DlTestSuperClass {
public int $a;
public int $temporary = 0;
public function test(string $str = ""): string {}
}
+7 -1
View File
@@ -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;
}
@@ -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));
@@ -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)
}
+25 -6
View File
@@ -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(