forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix phpGH-17577: JIT packed type guard crash
When a guard check is created for a variable to check if it's a packed array, it is possible that there was no prior type check for that variable. This happens in the global scope for example when the variable aliases. In the test, this causes a dereference of address 8 because the integer element in `$a` is interpreted as an array address. This patch adds a type check if a prior one was not inserted. In the aliasing case we also cannot set the stack type nor clear the MAY_BE_GUARD flag.
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
GH-17577 (JIT packed type guard crash) | ||
--EXTENSIONS-- | ||
opcache | ||
--INI-- | ||
opcache.jit_buffer_size=16M | ||
opcache.jit_hot_func=1 | ||
--FILE-- | ||
<?php | ||
$a = array( | ||
array(1,2,3), | ||
0, | ||
); | ||
function my_dump($var) { | ||
} | ||
foreach($a as $b) { | ||
for ($i = 0; $i < 3; $i++) { | ||
my_dump($b[$i]); | ||
} | ||
} | ||
?> | ||
--EXPECTF-- | ||
Warning: Trying to access array offset on int in %s on line %d | ||
|
||
Warning: Trying to access array offset on int in %s on line %d | ||
|
||
Warning: Trying to access array offset on int in %s on line %d |