diff options
-rw-r--r-- | ext/opcache/Optimizer/sccp.c | 8 | ||||
-rw-r--r-- | ext/opcache/tests/bug77434.phpt | 28 |
2 files changed, 34 insertions, 2 deletions
diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c index 90d59c0547..08e1584923 100644 --- a/ext/opcache/Optimizer/sccp.c +++ b/ext/opcache/Optimizer/sccp.c @@ -1118,6 +1118,10 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o SET_RESULT(result, data); SET_RESULT(op1, &zv); } else if (ct_eval_assign_dim(&zv, data, op2) == SUCCESS) { + /* Mark array containing partial array as partial */ + if (IS_PARTIAL_ARRAY(data)) { + MAKE_PARTIAL_ARRAY(&zv); + } SET_RESULT(result, data); SET_RESULT(op1, &zv); } else { @@ -2394,8 +2398,8 @@ int sccp_optimize_op_array(zend_optimizer_ctx *ctx, zend_op_array *op_array, zen } fprintf(stderr, " #%d.", i); zend_dump_var(op_array, IS_CV, ssa->vars[i].var); - if (IS_PARTIAL_ARRAY(zv)) { - fprintf(stderr, " = ["); + if (Z_TYPE_P(zv) == IS_ARRAY || IS_PARTIAL_ARRAY(zv)) { + fprintf(stderr, " = %s[", IS_PARTIAL_ARRAY(zv) ? "partial " : ""); zend_dump_ht(Z_ARRVAL_P(zv)); fprintf(stderr, "]"); } else if (IS_PARTIAL_OBJECT(zv)) { diff --git a/ext/opcache/tests/bug77434.phpt b/ext/opcache/tests/bug77434.phpt new file mode 100644 index 0000000000..5b8be3e174 --- /dev/null +++ b/ext/opcache/tests/bug77434.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #77434: php-fpm workers are segfaulting in zend_gc_addref +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +function test(int $x) { + $a = ['a' => 0, 'b' => $x]; + $b = []; + $b[0] = $a; + $c = $b[0]; +} + +function test2(int $x) { + $a = ['a' => 0, 'b' => $x]; + $b = [$a]; + $c = $b[0]; +} + +?> +===DONE=== +--EXPECT-- +===DONE=== |