Skip to content

Commit 91b5571

Browse files
committed
Fixed #79582 (Crash seen when opcache.jit=1235 and opcache.jit_debug=2)
1 parent ecc0a87 commit 91b5571

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ PHP NEWS
6767
. Removed deprecated INTL_IDNA_VARIANT_2003. (cmb)
6868

6969
- JIT:
70+
. Fixed bug #79582 (Crash seen when opcache.jit=1235 and
71+
opcache.jit_debug=2). (Laruence)
7072
. Fixed bug #77857 (Wrong result if executed with JIT). (Laruence)
7173
. Fixed bug #79255 (PHP cannot be compiled with enable JIT).
7274
(Laruence, Dmitry)

ext/opcache/jit/zend_jit.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,6 +3206,7 @@ void ZEND_FASTCALL zend_jit_hot_func(zend_execute_data *execute_data, const zend
32063206
static int zend_jit_setup_hot_counters(zend_op_array *op_array)
32073207
{
32083208
zend_op *opline = op_array->opcodes;
3209+
zend_func_info *func_info;
32093210
zend_jit_op_array_hot_extension *jit_extension;
32103211
zend_cfg cfg;
32113212
uint32_t i;
@@ -3218,6 +3219,14 @@ static int zend_jit_setup_hot_counters(zend_op_array *op_array)
32183219
}
32193220

32203221
jit_extension = (zend_jit_op_array_hot_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_hot_extension) + (op_array->last - 1) * sizeof(void*));
3222+
func_info = (zend_func_info*)ZEND_FUNC_INFO(op_array);
3223+
if (func_info) {
3224+
memcpy(&jit_extension->func_info, func_info, sizeof(zend_func_info));
3225+
} else {
3226+
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
3227+
jit_extension->func_info.num_args = -1;
3228+
jit_extension->func_info.return_value_used = -1;
3229+
}
32213230
jit_extension->counter = &zend_jit_hot_counters[zend_jit_op_array_hash(op_array) & (ZEND_HOT_COUNTERS_COUNT - 1)];
32223231
for (i = 0; i < op_array->last; i++) {
32233232
jit_extension->orig_handlers[i] = op_array->opcodes[i].handler;

ext/opcache/jit/zend_jit_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static zend_always_inline zend_long zend_jit_hash(const void *ptr)
5353
void ZEND_FASTCALL zend_jit_hot_func(zend_execute_data *execute_data, const zend_op *opline);
5454

5555
typedef struct _zend_jit_op_array_hot_extension {
56+
zend_func_info func_info;
5657
int16_t *counter;
5758
const void *orig_handlers[1];
5859
} zend_jit_op_array_hot_extension;

ext/opcache/jit/zend_jit_trace.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4984,6 +4984,7 @@ static zend_always_inline uint8_t zend_jit_trace_supported(const zend_op *opline
49844984
static int zend_jit_setup_hot_trace_counters(zend_op_array *op_array)
49854985
{
49864986
zend_op *opline;
4987+
zend_func_info *func_info;
49874988
zend_jit_op_array_trace_extension *jit_extension;
49884989
zend_cfg cfg;
49894990
uint32_t i;
@@ -4998,9 +4999,14 @@ static int zend_jit_setup_hot_trace_counters(zend_op_array *op_array)
49984999
}
49995000

50005001
jit_extension = (zend_jit_op_array_trace_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_trace_extension) + (op_array->last - 1) * sizeof(zend_op_trace_info));
5001-
memset(&jit_extension->func_info, 0, sizeof(jit_extension->func_info));
5002-
jit_extension->func_info.num_args = -1;
5003-
jit_extension->func_info.return_value_used = -1;
5002+
func_info = (zend_func_info*)ZEND_FUNC_INFO(op_array);
5003+
if (func_info) {
5004+
memcpy(&jit_extension->func_info, func_info, sizeof(zend_func_info));
5005+
} else {
5006+
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
5007+
jit_extension->func_info.num_args = -1;
5008+
jit_extension->func_info.return_value_used = -1;
5009+
}
50045010
jit_extension->offset = (char*)jit_extension->trace_info - (char*)op_array->opcodes;
50055011
for (i = 0; i < op_array->last; i++) {
50065012
jit_extension->trace_info[i].orig_handler = op_array->opcodes[i].handler;

0 commit comments

Comments
 (0)