Skip to content

Commit dd45d85

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix phpGH-16393: Assertion failure in ext/opcache/jit/zend_jit.c:2897
2 parents 0b657fe + bf786d0 commit dd45d85

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

ext/opcache/jit/zend_jit.c

+10-5
Original file line numberDiff line numberDiff line change
@@ -4213,16 +4213,19 @@ static void zend_jit_cleanup_func_info(zend_op_array *op_array)
42134213
}
42144214
}
42154215

4216-
static int zend_real_jit_func(zend_op_array *op_array, zend_script *script, const zend_op *rt_opline)
4216+
static int zend_real_jit_func(zend_op_array *op_array, zend_script *script, const zend_op *rt_opline, uint8_t trigger)
42174217
{
42184218
zend_ssa ssa;
42194219
void *checkpoint;
42204220
zend_func_info *func_info;
4221+
uint8_t orig_trigger;
42214222

42224223
if (*dasm_ptr == dasm_end) {
42234224
return FAILURE;
42244225
}
42254226

4227+
orig_trigger = JIT_G(trigger);
4228+
JIT_G(trigger) = trigger;
42264229
checkpoint = zend_arena_checkpoint(CG(arena));
42274230

42284231
/* Build SSA */
@@ -4255,11 +4258,13 @@ static int zend_real_jit_func(zend_op_array *op_array, zend_script *script, cons
42554258

42564259
zend_jit_cleanup_func_info(op_array);
42574260
zend_arena_release(&CG(arena), checkpoint);
4261+
JIT_G(trigger) = orig_trigger;
42584262
return SUCCESS;
42594263

42604264
jit_failure:
42614265
zend_jit_cleanup_func_info(op_array);
42624266
zend_arena_release(&CG(arena), checkpoint);
4267+
JIT_G(trigger) = orig_trigger;
42634268
return FAILURE;
42644269
}
42654270

@@ -4290,7 +4295,7 @@ static int ZEND_FASTCALL zend_runtime_jit(void)
42904295
opline->handler = jit_extension->orig_handler;
42914296

42924297
/* perform real JIT for this function */
4293-
zend_real_jit_func(op_array, NULL, NULL);
4298+
zend_real_jit_func(op_array, NULL, NULL, ZEND_JIT_ON_FIRST_EXEC);
42944299
} zend_catch {
42954300
do_bailout = true;
42964301
} zend_end_try();
@@ -4336,7 +4341,7 @@ void zend_jit_check_funcs(HashTable *function_table, bool is_method) {
43364341
jit_extension = (zend_jit_op_array_extension*)ZEND_FUNC_INFO(op_array);
43374342
opline->handler = jit_extension->orig_handler;
43384343
if (((double)counter / (double)zend_jit_profile_counter) > JIT_G(prof_threshold)) {
4339-
zend_real_jit_func(op_array, NULL, NULL);
4344+
zend_real_jit_func(op_array, NULL, NULL, ZEND_JIT_ON_PROF_REQUEST);
43404345
}
43414346
}
43424347
} ZEND_HASH_FOREACH_END();
@@ -4362,7 +4367,7 @@ void ZEND_FASTCALL zend_jit_hot_func(zend_execute_data *execute_data, const zend
43624367
}
43634368

43644369
/* perform real JIT for this function */
4365-
zend_real_jit_func(op_array, NULL, opline);
4370+
zend_real_jit_func(op_array, NULL, opline, ZEND_JIT_ON_HOT_COUNTERS);
43664371
} zend_catch {
43674372
do_bailout = 1;
43684373
} zend_end_try();
@@ -4530,7 +4535,7 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script)
45304535
} else if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
45314536
return zend_jit_setup_hot_trace_counters(op_array);
45324537
} else if (JIT_G(trigger) == ZEND_JIT_ON_SCRIPT_LOAD) {
4533-
return zend_real_jit_func(op_array, script, NULL);
4538+
return zend_real_jit_func(op_array, script, NULL, ZEND_JIT_ON_SCRIPT_LOAD);
45344539
} else {
45354540
ZEND_UNREACHABLE();
45364541
}

ext/opcache/tests/jit/gh16393.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
GH-16393 (Assertion failure in ext/opcache/jit/zend_jit.c:2897)
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.jit=1215
7+
opcache.jit_buffer_size=64M
8+
--FILE--
9+
<?php
10+
ini_set('opcache.jit', 'tracing');
11+
class Test {
12+
}
13+
$appendProp2 = (function() {
14+
})->bindTo($test, Test::class);
15+
$appendProp2();
16+
?>
17+
--EXPECTF--
18+
Warning: Undefined variable $test in %sgh16393.php on line 6

0 commit comments

Comments
 (0)