Skip to content

Commit

Permalink
Fix JIT for recursive call with too few args
Browse files Browse the repository at this point in the history
We may not generate labels for all leading RECVs. Don't generate
a direct jump if we have less arguments than required.
  • Loading branch information
nikic committed Sep 14, 2021
1 parent 10e9f6b commit 10bbff8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -10019,7 +10019,8 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
}
}

if (!trace && op_array == &func->op_array) {
if (!trace && op_array == &func->op_array
&& num_args >= op_array->required_num_args) {
/* recursive call */
if (ZEND_OBSERVER_ENABLED) {
| SAVE_IP
Expand Down
20 changes: 20 additions & 0 deletions ext/opcache/tests/jit/recursive_wrong_args.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Recursive call with too few args
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=32M
--FILE--
<?php
function f($arg) {
f();
}
try {
f();
} catch (ArgumentCountError $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
Too few arguments to function f(), 0 passed in %s on line %d and exactly 1 expected

0 comments on commit 10bbff8

Please sign in to comment.