Skip to content

Commit 5c43e0c

Browse files
committed
Fixed incorrect assumption about reference counting
1 parent f1e6a7d commit 5c43e0c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3582,7 +3582,9 @@ static zend_always_inline int _zend_update_type_info(
35823582
tmp = MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
35833583
if (opline->result_type == IS_TMP_VAR) {
35843584
if (opline->opcode == ZEND_FETCH_R || opline->opcode == ZEND_FETCH_IS) {
3585-
tmp |= MAY_BE_RCN;
3585+
/* Variable reference counter may be decremented before use */
3586+
/* See: ext/opcache/tests/jit/fetch_r_001.phpt */
3587+
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
35863588
} else {
35873589
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
35883590
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
FETCH_R: 001 result reference counter may be decremented befor use
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
$x = [&$v];
11+
$y = 'x';
12+
$$y == [&$x[0]];
13+
?>
14+
DONE
15+
--EXPECT--
16+
DONE

0 commit comments

Comments
 (0)