From fc35a6b93cfbd5be83d61b226e1286254e4cbf73 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 15 Nov 2021 23:25:16 +0300 Subject: [PATCH] Tracing JIT: Fixed abstract stack consistency for [QM_]ASSIGN of CV to itself --- ext/opcache/jit/zend_jit_trace.c | 10 ++++++-- ext/opcache/tests/jit/qm_assign_002.phpt | 29 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 ext/opcache/tests/jit/qm_assign_002.phpt diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index d20e7060290..fa29a039977 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -5904,7 +5904,10 @@ done: ssa->var_info[ssa_op->result_def].has_range = 1; } } - if (ssa_op->op1_def >= 0) { + if (ssa_op->op1_def >= 0 + && (opline->opcode != ZEND_QM_ASSIGN + || opline->result_type != IS_CV + || opline->result.var != opline->op1.var)) { zend_uchar type = IS_UNKNOWN; if (!(ssa->var_info[ssa_op->op1_def].type & MAY_BE_GUARD) @@ -5963,7 +5966,10 @@ done: ssa->var_info[ssa_op->op1_def].has_range = 1; } } - if (ssa_op->op2_def >= 0) { + if (ssa_op->op2_def >= 0 + && (opline->opcode != ZEND_ASSIGN + || opline->op1_type != IS_CV + || opline->op1.var != opline->op2.var)) { zend_uchar type = IS_UNKNOWN; if (!(ssa->var_info[ssa_op->op2_def].type & MAY_BE_GUARD) diff --git a/ext/opcache/tests/jit/qm_assign_002.phpt b/ext/opcache/tests/jit/qm_assign_002.phpt new file mode 100644 index 00000000000..ebfb46e227e --- /dev/null +++ b/ext/opcache/tests/jit/qm_assign_002.phpt @@ -0,0 +1,29 @@ +--TEST-- +JIT QM_ASSIGN: 002 assign to it self +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +--FILE-- + +DONE +--EXPECTF-- +Warning: Undefined variable $a in %sqm_assign_002.php on line 4 + +Warning: Undefined variable $b in %sqm_assign_002.php on line 5 + +Warning: Undefined variable $a in %sqm_assign_002.php on line 4 + +Warning: Array to string conversion in %sqm_assign_002.php on line 5 +DONE \ No newline at end of file