Skip to content

Commit

Permalink
Tracing JIT: Fixed FETCH_DIM_R with packed array and negative key
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Sep 21, 2021
1 parent a86ed2d commit 4d4a175
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ext/opcache/jit/zend_jit_arm64.dasc
Expand Up @@ -5058,7 +5058,7 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
| b >2 // NOT_FOUND
}
}
if (op1_info & MAY_BE_ARRAY_NUMERIC_HASH) {
if (!packed_loaded || (op1_info & MAY_BE_ARRAY_NUMERIC_HASH)) {
|4:
if (!op2_loaded) {
| // hval = Z_LVAL_P(dim);
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/jit/zend_jit_x86.dasc
Expand Up @@ -5536,7 +5536,7 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
| jmp >2 // NOT_FOUND
}
}
if (op1_info & MAY_BE_ARRAY_NUMERIC_HASH) {
if (!packed_loaded || (op1_info & MAY_BE_ARRAY_NUMERIC_HASH)) {
|4:
if (!op2_loaded) {
| // hval = Z_LVAL_P(dim);
Expand Down
40 changes: 40 additions & 0 deletions ext/opcache/tests/jit/fetch_dim_r_005.phpt
@@ -0,0 +1,40 @@
--TEST--
JIT FETCH_DIM_R: 005
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
opcache.jit=tracing
--EXTENSIONS--
opcache
--FILE--
<?php
$gens = [];
for ($i = 0; $i < 5; $i++) {
$gens[] = $gens[-1];
}
var_dump($gens);
?>
--EXPECTF--
Warning: Undefined array key -1 in %sfetch_dim_r_005.php on line 4

Warning: Undefined array key -1 in %sfetch_dim_r_005.php on line 4

Warning: Undefined array key -1 in %sfetch_dim_r_005.php on line 4

Warning: Undefined array key -1 in %sfetch_dim_r_005.php on line 4

Warning: Undefined array key -1 in %sfetch_dim_r_005.php on line 4
array(5) {
[0]=>
NULL
[1]=>
NULL
[2]=>
NULL
[3]=>
NULL
[4]=>
NULL
}

0 comments on commit 4d4a175

Please sign in to comment.