From 983a4fc4a3c9aa72f34beaeba559ecb8762f0c30 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 22 Sep 2021 15:53:48 +0200 Subject: [PATCH] Fix ASSIGN_STATIC_PROP_REF type inference We were not inferring anything for the ASSIGN_STATIC_PROP_REF result type at all, leaving it as an empty type. In the test case this results in a live range being incorrectly eliminated, but this could break in all kinds of other ways as well.. --- ext/opcache/Optimizer/zend_inference.c | 3 +++ .../tests/assign_static_prop_ref_result.phpt | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 ext/opcache/tests/assign_static_prop_ref_result.phpt diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index 3ac243c30a3..a224ce605ca 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -2938,6 +2938,9 @@ static zend_always_inline int _zend_update_type_info( } break; case ZEND_ASSIGN_STATIC_PROP_REF: + if (ssa_op->result_def >= 0) { + UPDATE_SSA_TYPE(MAY_BE_REF, ssa_op->result_def); + } if ((opline+1)->op1_type == IS_CV) { opline++; ssa_op++; diff --git a/ext/opcache/tests/assign_static_prop_ref_result.phpt b/ext/opcache/tests/assign_static_prop_ref_result.phpt new file mode 100644 index 00000000000..7fef0d05e95 --- /dev/null +++ b/ext/opcache/tests/assign_static_prop_ref_result.phpt @@ -0,0 +1,14 @@ +--TEST-- +ASSIGN_STATIC_PROP_REF result should have live range +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught Error: Undefined constant "UNDEF" in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d