Skip to content

Commit 78c2e0e

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents 335fb94 + 902ec36 commit 78c2e0e

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.3.0RC5
44

5+
- Opcache:
6+
. Fixed bug #77058 (Type inference in opcache causes side effects). (Nikita)
7+
58
- SOAP:
69
. Fixed bug #50675 (SoapClient can't handle object references correctly).
710
(Cameron Porter)

ext/opcache/Optimizer/zend_inference.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,10 @@ static void handle_type_narrowing(const zend_op_array *op_array, zend_ssa *ssa,
20192019
{
20202020
if (1) {
20212021
/* Right now, this is always a bug */
2022-
zend_error(E_WARNING, "Narrowing occurred during type inference. Please file a bug report on bugs.php.net");
2022+
int def_op_num = ssa->vars[var].definition;
2023+
const zend_op *def_opline = def_op_num >= 0 ? &op_array->opcodes[def_op_num] : NULL;
2024+
const char *def_op_name = def_opline ? zend_get_opcode_name(def_opline->opcode) : "PHI";
2025+
zend_error(E_WARNING, "Narrowing occurred during type inference of %s. Please file a bug report on bugs.php.net", def_op_name);
20232026
} else {
20242027
/* if new_type set resets some bits from old_type set
20252028
* We have completely recalculate types of some dependent SSA variables
@@ -2555,7 +2558,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
25552558
tmp |= MAY_BE_RCN;
25562559
}
25572560
}
2558-
if ((t1 & MAY_BE_ANY) == MAY_BE_LONG) {
2561+
if ((t1 & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG) {
25592562
if (!ssa_var_info[ssa_ops[i].op1_use].has_range ||
25602563
(opline->opcode == ZEND_PRE_DEC &&
25612564
(ssa_var_info[ssa_ops[i].op1_use].range.underflow ||
@@ -2617,7 +2620,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
26172620
if (t1 & (MAY_BE_RC1|MAY_BE_RCN)) {
26182621
tmp |= MAY_BE_RC1;
26192622
}
2620-
if ((t1 & MAY_BE_ANY) == MAY_BE_LONG) {
2623+
if ((t1 & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG) {
26212624
if (!ssa_var_info[ssa_ops[i].op1_use].has_range ||
26222625
(opline->opcode == ZEND_PRE_DEC &&
26232626
(ssa_var_info[ssa_ops[i].op1_use].range.underflow ||

ext/opcache/tests/bug77058.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #77058: Type inference in opcache causes side effects
3+
--FILE--
4+
<?php
5+
6+
function myfunc(){
7+
$Nr = 0;
8+
while(1){
9+
$x--;
10+
$x++;
11+
if( ++ $Nr >= 2 ) break;
12+
}
13+
echo "'$Nr' is expected to be 2", PHP_EOL;
14+
}
15+
myfunc();
16+
17+
?>
18+
--EXPECTF--
19+
Notice: Undefined variable: x in %s on line %d
20+
'2' is expected to be 2

0 commit comments

Comments
 (0)