From 33fa02ea3823a38034b79bc97b52e6d10bee4d24 Mon Sep 17 00:00:00 2001 From: Joe Watkins Date: Wed, 24 Oct 2018 08:43:27 +0200 Subject: [PATCH 1/4] bump versions --- NEWS | 6 +++++- configure.in | 2 +- main/php_version.h | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 399bb1ce566..f90f0b0fbe8 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? 2018, PHP 7.1.24 +?? ??? 2018, PHP 7.1.25 + + + +08 Nov 2018, PHP 7.1.24 - Core: . Fixed bug #76946 (Cyclic reference in generator not detected). (Nikita) diff --git a/configure.in b/configure.in index 3cb3335709a..a27260ac8ab 100644 --- a/configure.in +++ b/configure.in @@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...); PHP_MAJOR_VERSION=7 PHP_MINOR_VERSION=1 -PHP_RELEASE_VERSION=24 +PHP_RELEASE_VERSION=25 PHP_EXTRA_VERSION="-dev" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION` diff --git a/main/php_version.h b/main/php_version.h index c5ddedfe69d..2a11270320e 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,7 +2,7 @@ /* edit configure.in to change version number */ #define PHP_MAJOR_VERSION 7 #define PHP_MINOR_VERSION 1 -#define PHP_RELEASE_VERSION 24 +#define PHP_RELEASE_VERSION 25 #define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "7.1.24-dev" -#define PHP_VERSION_ID 70124 +#define PHP_VERSION "7.1.25-dev" +#define PHP_VERSION_ID 70125 From e7153e8a2f5ea6e2b2d2b5afe558deebf518f04a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 25 Oct 2018 16:18:10 +0200 Subject: [PATCH 2/4] Improve "narrowing" error message By including the opcode name. --- ext/opcache/Optimizer/zend_inference.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index 89bd75c1ed7..6aa823fdd2f 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -1927,7 +1927,10 @@ static void handle_type_narrowing(const zend_op_array *op_array, zend_ssa *ssa, { if (1) { /* Right now, this is always a bug */ - zend_error(E_WARNING, "Narrowing occurred during type inference. Please file a bug report on bugs.php.net"); + int def_op_num = ssa->vars[var].definition; + const zend_op *def_opline = def_op_num >= 0 ? &op_array->opcodes[def_op_num] : NULL; + const char *def_op_name = def_opline ? zend_get_opcode_name(def_opline->opcode) : "PHI"; + zend_error(E_WARNING, "Narrowing occurred during type inference of %s. Please file a bug report on bugs.php.net", def_op_name); } else { /* if new_type set resets some bits from old_type set * We have completely recalculate types of some dependent SSA variables From f1ceec5533c5ee0e1de7867d629f336f1353f4b3 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 25 Oct 2018 16:25:54 +0200 Subject: [PATCH 3/4] Fixed bug #77058 Account for the fact that undef must be interpreted as null for the purposes of INC/DEC inference. --- NEWS | 3 ++- ext/opcache/Optimizer/zend_inference.c | 4 ++-- ext/opcache/tests/bug77058.phpt | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 ext/opcache/tests/bug77058.phpt diff --git a/NEWS b/NEWS index f90f0b0fbe8..c801b72b4ea 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2018, PHP 7.1.25 - +- Opcache: + . Fixed bug #77058 (Type inference in opcache causes side effects). (Nikita) 08 Nov 2018, PHP 7.1.24 diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index 6aa823fdd2f..39cab72195a 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -2434,7 +2434,7 @@ static int zend_update_type_info(const zend_op_array *op_array, tmp |= MAY_BE_RCN; } } - if ((t1 & MAY_BE_ANY) == MAY_BE_LONG) { + if ((t1 & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG) { if (!ssa_var_info[ssa_ops[i].op1_use].has_range || (opline->opcode == ZEND_PRE_DEC && (ssa_var_info[ssa_ops[i].op1_use].range.underflow || @@ -2496,7 +2496,7 @@ static int zend_update_type_info(const zend_op_array *op_array, if (t1 & (MAY_BE_RC1|MAY_BE_RCN)) { tmp |= MAY_BE_RC1; } - if ((t1 & MAY_BE_ANY) == MAY_BE_LONG) { + if ((t1 & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG) { if (!ssa_var_info[ssa_ops[i].op1_use].has_range || (opline->opcode == ZEND_PRE_DEC && (ssa_var_info[ssa_ops[i].op1_use].range.underflow || diff --git a/ext/opcache/tests/bug77058.phpt b/ext/opcache/tests/bug77058.phpt new file mode 100644 index 00000000000..6a5a83cef7a --- /dev/null +++ b/ext/opcache/tests/bug77058.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #77058: Type inference in opcache causes side effects +--FILE-- += 2 ) break; + } + echo "'$Nr' is expected to be 2", PHP_EOL; +} +myfunc(); + +?> +--EXPECTF-- +Notice: Undefined variable: x in %s on line %d +'2' is expected to be 2 From b9431ef4d5c07c19cd141fdb430e3fd763db257c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 25 Oct 2018 16:31:10 +0200 Subject: [PATCH 4/4] Don't optimize function if inference failed This was respected only for the single-function optimizations, not in func-info mode. --- ext/opcache/Optimizer/zend_optimizer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c index 3904a6d35ad..bdfd52d8d10 100644 --- a/ext/opcache/Optimizer/zend_optimizer.c +++ b/ext/opcache/Optimizer/zend_optimizer.c @@ -1488,8 +1488,11 @@ int zend_optimize_script(zend_script *script, zend_long optimization_level, zend for (i = 0; i < call_graph.op_arrays_count; i++) { func_info = ZEND_FUNC_INFO(call_graph.op_arrays[i]); if (func_info) { - zend_dfa_analyze_op_array(call_graph.op_arrays[i], &ctx, &func_info->ssa); - func_info->flags = func_info->ssa.cfg.flags; + if (zend_dfa_analyze_op_array(call_graph.op_arrays[i], &ctx, &func_info->ssa) == SUCCESS) { + func_info->flags = func_info->ssa.cfg.flags; + } else { + ZEND_SET_FUNC_INFO(call_graph.op_arrays[i], NULL); + } } }