Skip to content

Fix GH-16984: function JIT overflow bug #17015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2024
Merged
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
4 changes: 2 additions & 2 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -7204,9 +7204,9 @@ static int zend_jit_cmp(zend_jit_ctx *jit,

while (n) {
n--;
ir_IF_TRUE(end_inputs->refs[n]);
jit_IF_TRUE_FALSE_ex(jit, end_inputs->refs[n], label);
ir_END_list(true_inputs);
ir_IF_FALSE(end_inputs->refs[n]);
jit_IF_TRUE_FALSE_ex(jit, end_inputs->refs[n], label2);
ir_END_list(false_inputs);
}
ir_MERGE_list(true_inputs);
Expand Down
41 changes: 41 additions & 0 deletions ext/opcache/tests/jit/gh16984.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--TEST--
GH-16984 (function JIT overflow bug)
--EXTENSIONS--
opcache
--SKIPIF--
<?php if (PHP_INT_SIZE != 8) die("skip: 64-bit only"); ?>
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=32M
opcache.jit=function
--FILE--
<?php

final class Test {
public int $integer = -1;

public function foo(int $x) {
return $x;
}
}

function foo(Test $test, int $value) {
$val = $test->foo($value);
if ($val <= PHP_INT_MAX) {
$test->integer = $val;
}
}

function main() {
$test = new Test;
foo($test, 9223372036854775806);
foo($test, 9223372036854775807); // Also reproduces without this call, but this imitates the psalm code
var_dump($test->integer);
}

main();
?>
--EXPECT--
int(9223372036854775807)