Skip to content

Commit b2eff1f

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix GH-15973: Segmentation fault in JIT mode 1135 (#16006)
2 parents 102ff9f + e3507cb commit b2eff1f

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13740,7 +13740,9 @@ static int zend_jit_load_this(zend_jit_ctx *jit, uint32_t var)
1374013740

1374113741
static int zend_jit_fetch_this(zend_jit_ctx *jit, const zend_op *opline, const zend_op_array *op_array, bool check_only)
1374213742
{
13743-
if (!op_array->scope || (op_array->fn_flags & ZEND_ACC_STATIC)) {
13743+
if (!op_array->scope ||
13744+
(op_array->fn_flags & ZEND_ACC_STATIC) ||
13745+
((op_array->fn_flags & (ZEND_ACC_CLOSURE|ZEND_ACC_IMMUTABLE)) == ZEND_ACC_CLOSURE)) {
1374413746
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
1374513747
if (!JIT_G(current_frame) ||
1374613748
!TRACE_FRAME_IS_THIS_CHECKED(JIT_G(current_frame))) {

ext/opcache/tests/jit/gh15973.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GH-15973 (Segmentation fault in JIT mode 1135)
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.jit=1215
7+
opcache.jit_buffer_size=64M
8+
--FILE--
9+
<?php
10+
class Test {
11+
}
12+
$appendProp2 = (function() {
13+
$this->prop[] = 1;
14+
})->bindTo($test, Test::class);
15+
$appendProp2();
16+
?>
17+
--EXPECTF--
18+
Warning: Undefined variable $test in %sgh15973.php on line 6
19+
20+
Fatal error: Uncaught Error: Using $this when not in object context in %sgh15973.php:5
21+
Stack trace:
22+
#0 %sgh15973.php(7): Test::{closure:%s}()
23+
#1 {main}
24+
thrown in %sgh15973.php on line 5

0 commit comments

Comments
 (0)