From 606eb849bb11eae1fa35712ca80ad42b773ebf4a Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 26 Aug 2024 17:26:18 +0200 Subject: [PATCH] Stop recording of trace when encountering hook Fixes GH-15178 --- NEWS | 1 + ext/opcache/jit/zend_jit_internal.h | 1 + ext/opcache/jit/zend_jit_vm_helpers.c | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/NEWS b/NEWS index df968d86ccb..0322b9b452d 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,7 @@ PHP NEWS - Opcache: . Fixed bug GH-15490 (Building of callgraph modifies preloaded symbols). (ilutov) + . Fixed bug GH-15178 (Assertion in tracing JIT on hooks). (ilutov) - PDO_MYSQL: . mysqlnd: support ER_CLIENT_INTERACTION_TIMEOUT. (Appla) diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h index ccc86a4834c..2007f28e91f 100644 --- a/ext/opcache/jit/zend_jit_internal.h +++ b/ext/opcache/jit/zend_jit_internal.h @@ -265,6 +265,7 @@ zend_constant* ZEND_FASTCALL zend_jit_check_constant(const zval *key); _(INNER_LOOP, "inner loop") /* trace it */ \ _(COMPILED_LOOP, "compiled loop") \ _(TRAMPOLINE, "trampoline call") \ + _(PROP_HOOK_CALL, "property hook call") \ _(BAD_FUNC, "bad function call") \ _(COMPILER_ERROR, "JIT compilation error") \ /* no recoverable error (blacklist immediately) */ \ diff --git a/ext/opcache/jit/zend_jit_vm_helpers.c b/ext/opcache/jit/zend_jit_vm_helpers.c index 2a7399c185d..e9cdeeab986 100644 --- a/ext/opcache/jit/zend_jit_vm_helpers.c +++ b/ext/opcache/jit/zend_jit_vm_helpers.c @@ -503,6 +503,11 @@ static int zend_jit_trace_record_fake_init_call_ex(zend_execute_data *call, zend /* TODO: Can we continue recording ??? */ return -1; } + /* Function is a property hook. */ + if (func->common.prop_info) { + /* TODO: Can we continue recording ??? */ + return -1; + } if (func->type == ZEND_INTERNAL_FUNCTION && (func->op_array.fn_flags & (ZEND_ACC_CLOSURE|ZEND_ACC_FAKE_CLOSURE))) { return -1; @@ -966,6 +971,12 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex, break; } + if (EX(func)->op_array.prop_info) { + /* TODO: Can we continue recording ??? */ + stop = ZEND_JIT_TRACE_STOP_PROP_HOOK_CALL; + break; + } + TRACE_RECORD(ZEND_JIT_TRACE_ENTER, EX(return_value) != NULL ? ZEND_JIT_TRACE_RETURN_VALUE_USED : 0, op_array); @@ -1069,6 +1080,10 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex, /* TODO: Can we continue recording ??? */ stop = ZEND_JIT_TRACE_STOP_BAD_FUNC; break; + } else if (EX(call)->func->common.prop_info) { + /* TODO: Can we continue recording ??? */ + stop = ZEND_JIT_TRACE_STOP_PROP_HOOK_CALL; + break; } func = EX(call)->func; if (func->type == ZEND_INTERNAL_FUNCTION