Skip to content

Commit ade702a

Browse files
committed
Fixed bug #77434
Mark arrays containing partial arrays as partial. This was already done for the ADD_ARRAY_ELEMENT case, but not for ASSIGN_DIM.
1 parent 16176ad commit ade702a

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ PHP NEWS
3333
. Fixed bug #77266 (Assertion failed in dce_live_ranges). (Laruence)
3434
. Fixed bug #77257 (value of variable assigned in a switch() construct gets
3535
lost). (Nikita)
36+
. Fixed bug #77434 (php-fpm workers are segfaulting in zend_gc_addre).
37+
(Nikita)
3638

3739
- PCRE:
3840
. Fixed bug #77338 (get_browser with empty string). (Nikita)

ext/opcache/Optimizer/sccp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,10 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
11021102
SET_RESULT(result, data);
11031103
SET_RESULT(op1, &zv);
11041104
} else if (ct_eval_assign_dim(&zv, data, op2) == SUCCESS) {
1105+
/* Mark array containing partial array as partial */
1106+
if (IS_PARTIAL_ARRAY(data)) {
1107+
MAKE_PARTIAL_ARRAY(&zv);
1108+
}
11051109
SET_RESULT(result, data);
11061110
SET_RESULT(op1, &zv);
11071111
} else {
@@ -2368,8 +2372,8 @@ int sccp_optimize_op_array(zend_optimizer_ctx *ctx, zend_op_array *op_array, zen
23682372
}
23692373
fprintf(stderr, " #%d.", i);
23702374
zend_dump_var(op_array, IS_CV, ssa->vars[i].var);
2371-
if (IS_PARTIAL_ARRAY(zv)) {
2372-
fprintf(stderr, " = [");
2375+
if (Z_TYPE_P(zv) == IS_ARRAY || IS_PARTIAL_ARRAY(zv)) {
2376+
fprintf(stderr, " = %s[", IS_PARTIAL_ARRAY(zv) ? "partial " : "");
23732377
zend_dump_ht(Z_ARRVAL_P(zv));
23742378
fprintf(stderr, "]");
23752379
} else if (IS_PARTIAL_OBJECT(zv)) {

ext/opcache/tests/bug77434.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Bug #77434: php-fpm workers are segfaulting in zend_gc_addref
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
12+
function test(int $x) {
13+
$a = ['a' => 0, 'b' => $x];
14+
$b = [];
15+
$b[0] = $a;
16+
$c = $b[0];
17+
}
18+
19+
function test2(int $x) {
20+
$a = ['a' => 0, 'b' => $x];
21+
$b = [$a];
22+
$c = $b[0];
23+
}
24+
25+
?>
26+
===DONE===
27+
--EXPECT--
28+
===DONE===

0 commit comments

Comments
 (0)