Skip to content

Commit dc0987d

Browse files
authored
Fix GH-15973: Segmentation fault in JIT mode 1135 (#16006)
1 parent 89b5cc3 commit dc0987d

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13829,7 +13829,9 @@ static int zend_jit_load_this(dasm_State **Dst, uint32_t var)
1382913829

1383013830
static int zend_jit_fetch_this(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, bool check_only)
1383113831
{
13832-
if (!op_array->scope || (op_array->fn_flags & ZEND_ACC_STATIC)) {
13832+
if (!op_array->scope ||
13833+
(op_array->fn_flags & ZEND_ACC_STATIC) ||
13834+
((op_array->fn_flags & (ZEND_ACC_CLOSURE|ZEND_ACC_IMMUTABLE)) == ZEND_ACC_CLOSURE)) {
1383313835
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
1383413836
if (!JIT_G(current_frame) ||
1383513837
!TRACE_FRAME_IS_THIS_CHECKED(JIT_G(current_frame))) {

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14749,7 +14749,9 @@ static int zend_jit_load_this(dasm_State **Dst, uint32_t var)
1474914749

1475014750
static int zend_jit_fetch_this(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, bool check_only)
1475114751
{
14752-
if (!op_array->scope || (op_array->fn_flags & ZEND_ACC_STATIC)) {
14752+
if (!op_array->scope ||
14753+
(op_array->fn_flags & ZEND_ACC_STATIC) ||
14754+
((op_array->fn_flags & (ZEND_ACC_CLOSURE|ZEND_ACC_IMMUTABLE)) == ZEND_ACC_CLOSURE)) {
1475314755
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
1475414756
if (!JIT_G(current_frame) ||
1475514757
!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}()
23+
#1 {main}
24+
thrown in %sgh15973.php on line 5

0 commit comments

Comments
 (0)