From 57fda2d6794b4f622de63b91e6dc1de21396edb5 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 16 Oct 2024 13:17:26 +0300 Subject: [PATCH] Fix invalid target opline with jit->reuse_ip active This is an alternative for #16440 --- ext/opcache/jit/zend_jit_ir.c | 16 ++++++++++++ ext/opcache/tests/jit/init_fcall_004.phpt | 31 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 ext/opcache/tests/jit/init_fcall_004.phpt diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index c3ab026deec2f..c12298aaf3fda 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -8794,6 +8794,14 @@ jit_SET_EX_OPLINE(jit, opline); delayed_call_chain = 1; } + if (trace + && trace->op == ZEND_JIT_TRACE_END + && trace->stop == ZEND_JIT_TRACE_STOP_INTERPRETER) { + if (!zend_jit_set_ip(jit, opline + 1)) { + return 0; + } + } + return 1; } @@ -9057,6 +9065,14 @@ static int zend_jit_init_method_call(zend_jit_ctx *jit, jit->delayed_call_level = call_level; } + if (trace + && trace->op == ZEND_JIT_TRACE_END + && trace->stop == ZEND_JIT_TRACE_STOP_INTERPRETER) { + if (!zend_jit_set_ip(jit, opline + 1)) { + return 0; + } + } + return 1; } diff --git a/ext/opcache/tests/jit/init_fcall_004.phpt b/ext/opcache/tests/jit/init_fcall_004.phpt new file mode 100644 index 0000000000000..68219d0273683 --- /dev/null +++ b/ext/opcache/tests/jit/init_fcall_004.phpt @@ -0,0 +1,31 @@ +--TEST-- +JIT INIT_FCALL: 004 Invalid target opline with jit->reuse_ip active +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +--EXTENSIONS-- +opcache +--FILE-- + +DONE +--EXPECT-- +int(1) +int(2) +int(1) +int(2) +DONE