Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -14105,6 +14105,13 @@ static int zend_jit_fe_fetch(zend_jit_ctx *jit, const zend_op *opline, uint32_t
return 0;
}
} else {
// JIT: ZVAL_DEREF(value);
if (val_info & MAY_BE_REF) {
ir_ref ref = jit_ZVAL_ADDR(jit, val_addr);
ref = jit_ZVAL_DEREF_ref(jit, ref);
val_addr = ZEND_ADDR_REF_ZVAL(ref);
val_info &= ~MAY_BE_REF;
}
// JIT: ZVAL_COPY(res, value);
jit_ZVAL_COPY(jit, var_addr, -1, val_addr, val_info, true);
}
Expand Down
47 changes: 47 additions & 0 deletions ext/opcache/tests/jit/gh21264-1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
--TEST--
GH-21264: Missing reference unwrap for FE_FETCH_R in JIT
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=function
--FILE--
<?php

class C {
public array $array;

public static function identity($x) {
return $x;
}

public function test() {
return array_map(self::identity(...), $this->array);
}
}

function test() {
$c = new C;
$element = 'qux';
$c->array = [&$element, &$element];
var_dump($c->test());
}

test();
test();

?>
--EXPECT--
array(2) {
[0]=>
string(3) "qux"
[1]=>
string(3) "qux"
}
array(2) {
[0]=>
string(3) "qux"
[1]=>
string(3) "qux"
}
31 changes: 31 additions & 0 deletions ext/opcache/tests/jit/gh21264-2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
GH-21264: Missing reference unwrap for FE_FETCH_R in JIT
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=tracing
--FILE--
<?php

class C {
public $prop = 0;
}

function test($array) {
$c = new C;
foreach ($array as $c->prop) {
$c->prop++;
}
}

$element = 0;
$array = [&$element, &$element];
test($array);
test($array);
var_dump($element);

?>
--EXPECT--
int(0)
Loading