mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix segfault when preloading constant AST closure
Fixes GH-21059 Closes GH-21071
This commit is contained in:
1
NEWS
1
NEWS
@@ -4,6 +4,7 @@ PHP NEWS
|
||||
|
||||
- Core:
|
||||
. Fixed bug GH-21029 (zend_mm_heap corrupted on Aarch64, LTO builds). (Arnaud)
|
||||
. Fixed bug GH-21059 (Segfault when preloading constant AST closure). (ilutov)
|
||||
|
||||
- Windows:
|
||||
. Fixed compilation with clang (missing intrin.h include). (Kévin Dunglas)
|
||||
|
||||
@@ -1154,6 +1154,12 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner(
|
||||
}
|
||||
case ZEND_AST_OP_ARRAY:
|
||||
{
|
||||
// Preloading will attempt to resolve constants but objects can't be stored in shm
|
||||
// Aborting here to store the const AST instead
|
||||
if (CG(in_compilation)) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
zend_function *func = (zend_function *)zend_ast_get_op_array(ast)->op_array;
|
||||
|
||||
zend_create_closure(result, func, scope, scope, NULL);
|
||||
|
||||
7
ext/opcache/tests/preload_gh21059.inc
Normal file
7
ext/opcache/tests/preload_gh21059.inc
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Foo {
|
||||
public const C = static function() {
|
||||
echo "Hello world\n";
|
||||
};
|
||||
}
|
||||
18
ext/opcache/tests/preload_gh21059.phpt
Normal file
18
ext/opcache/tests/preload_gh21059.phpt
Normal file
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
GH-21059: Segfault when preloading constant AST closure
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.preload={PWD}/preload_gh21059.inc
|
||||
--EXTENSIONS--
|
||||
opcache
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
(Foo::C)();
|
||||
?>
|
||||
--EXPECT--
|
||||
Hello world
|
||||
Reference in New Issue
Block a user