Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/dl_test/dl_test.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function test(string $str = ""): string {}

class DlTestSuperClass {
public int $a;
public int $temporary = 0;
public function test(string $str = ""): string {}
}

Expand Down
8 changes: 7 additions & 1 deletion ext/dl_test/dl_test_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions ext/dl_test/tests/opcache_temporary_strings.inc
Original file line number Diff line number Diff line change
@@ -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));
22 changes: 22 additions & 0 deletions ext/dl_test/tests/opcache_temporary_strings.phpt
Original file line number Diff line number Diff line change
@@ -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)
}
23 changes: 17 additions & 6 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ static zend_string* ZEND_FASTCALL accel_new_interned_string_for_php(zend_string
return ret;
}
}
if (!ZSTR_IS_INTERNED(str) && (GC_FLAGS(str) & GC_PERSISTENT)) {
GC_MAKE_PERSISTENT_LOCAL(str);
}
return str;
}

Expand All @@ -602,19 +605,27 @@ 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);
}

if (permanent) {
GC_MAKE_PERSISTENT_LOCAL(ret);
}

return zend_string_init(str, size, permanent);
return ret;
}

static inline void accel_copy_permanent_list_types(
Expand Down
Loading