mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Fixed bug #81256 (Assertion `zv != ((void *)0)' failed for "preload" with JIT)
This commit is contained in:
parent
2378f35787
commit
1e4095f03d
2
NEWS
2
NEWS
@ -11,6 +11,8 @@ PHP NEWS
|
||||
(Dmitry)
|
||||
. Fixed bug #81249 (Intermittent property assignment failure with JIT
|
||||
enabled). (Dmitry)
|
||||
. Fixed bug #81256 (Assertion `zv != ((void *)0)' failed for "preload" with
|
||||
JIT). (Dmitry)
|
||||
|
||||
- Reflection:
|
||||
. Fixed bug #80097 (ReflectionAttribute is not a Reflector). (beberlei)
|
||||
|
@ -4086,6 +4086,7 @@ static void preload_link(void)
|
||||
zend_op_array *op_array = &script->script.main_op_array;
|
||||
zend_op *opline = op_array->opcodes;
|
||||
zend_op *end = opline + op_array->last;
|
||||
uint32_t skip_dynamic_func_count = 0;
|
||||
|
||||
while (opline != end) {
|
||||
switch (opline->opcode) {
|
||||
@ -4096,6 +4097,40 @@ static void preload_link(void)
|
||||
MAKE_NOP(opline);
|
||||
}
|
||||
break;
|
||||
case ZEND_DECLARE_FUNCTION:
|
||||
opline->op2.num -= skip_dynamic_func_count;
|
||||
key = Z_STR_P(RT_CONSTANT(opline, opline->op1));
|
||||
zv = zend_hash_find(EG(function_table), key);
|
||||
if (zv && Z_PTR_P(zv) == op_array->dynamic_func_defs[opline->op2.num]) {
|
||||
zend_op_array **dynamic_func_defs;
|
||||
|
||||
op_array->num_dynamic_func_defs--;
|
||||
if (op_array->num_dynamic_func_defs == 0) {
|
||||
dynamic_func_defs = NULL;
|
||||
} else {
|
||||
dynamic_func_defs = emalloc(sizeof(zend_op_array*) * op_array->num_dynamic_func_defs);
|
||||
if (opline->op2.num > 0) {
|
||||
memcpy(
|
||||
dynamic_func_defs,
|
||||
op_array->dynamic_func_defs,
|
||||
sizeof(zend_op_array*) * opline->op2.num);
|
||||
}
|
||||
if (op_array->num_dynamic_func_defs - opline->op2.num > 0) {
|
||||
memcpy(
|
||||
dynamic_func_defs + opline->op2.num,
|
||||
op_array->dynamic_func_defs + (opline->op2.num + 1),
|
||||
sizeof(zend_op_array*) * (op_array->num_dynamic_func_defs - opline->op2.num));
|
||||
}
|
||||
}
|
||||
efree(op_array->dynamic_func_defs);
|
||||
op_array->dynamic_func_defs = dynamic_func_defs;
|
||||
skip_dynamic_func_count++;
|
||||
MAKE_NOP(opline);
|
||||
}
|
||||
break;
|
||||
case ZEND_DECLARE_LAMBDA_FUNCTION:
|
||||
opline->op2.num -= skip_dynamic_func_count;
|
||||
break;
|
||||
}
|
||||
opline++;
|
||||
}
|
||||
|
16
ext/opcache/tests/jit/bug81256.phpt
Normal file
16
ext/opcache/tests/jit/bug81256.phpt
Normal file
@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
Bug #81256: Assertion `zv != ((void *)0)' failed for "preload" with JIT
|
||||
--EXTENSIONS--
|
||||
opcache
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.jit_buffer_size=1M
|
||||
opcache.jit=function
|
||||
opcache.preload={PWD}/preload_bug81256.inc
|
||||
--FILE--
|
||||
<?php
|
||||
foo();
|
||||
?>
|
||||
--EXPECT--
|
||||
Hello
|
7
ext/opcache/tests/jit/preload_bug81256.inc
Normal file
7
ext/opcache/tests/jit/preload_bug81256.inc
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
$a = true;
|
||||
if ($a) {
|
||||
function foo(...$arg) {
|
||||
echo "Hello\n";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user