-
Notifications
You must be signed in to change notification settings - Fork 7.8k
JIT Index invalid or out of range error #12382
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
Comments
Reproducible only using tracing JIT, not e.g. function JIT. |
Basic reproducer: <?php
function applyMaskPenaltyRule3(array $array) : void
{
for ($y = 0; $y < 21; ++$y) {
for ($x = 0; $x < 21; ++$x) {
if (
(
$x + 10 < 21
&& 0 === $array[$y][$x + 7]
)
|| (
$x - 4 >= 0
&& 0 === $array[$y][$x - 1]
)
) {
}
}
}
}
$matrix = [[1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, ], [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, ], [1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, ], [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, ], [1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, ], [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, ], [1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, ], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], [0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, ], [0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, ], [0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, ], [1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, ], [1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, ], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, ], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, ], [1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, ], [1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, ], [1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, ], [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, ], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, ], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, ], ];
applyMaskPenaltyRule3($matrix);
applyMaskPenaltyRule3($matrix); Emits
Only if tracing JIT is enabled. |
@nielsdos @dstogov A thing that's been bothering me this bug in particular is that it could in theory be reproduced with an appropriate testcase, combined with the For example, adding the following testcase to public function testEncodeSmall() : void
{
$qrCode = Encoder::encode('a', ErrorCorrectionLevel::H());
$this->assertTrue(true);
} And running the entire testsuite with:
does not reproduce the issue, while running just that testcase with:
does. I've been thinking of adding a Any idea of the possible cause? |
The issue seems to be related to the skipping of comparisons. If I remove the strict comparison and just use a boolean cast it works. Disabling the optimization with ZEND_SUB in the first case of Looking at the diff in assembly instructions between forcing skip_comparison to off and normal execution shows this: mov 0x70(%r14), %rcx
lea -0x4(%rcx), %rax
+ test %rax, %rax
jge jit$$trace_exit_0 So: in the working version there's an additional test instruction. It seems that the subtraction was implemented with a lea instruction, but lea does NOT set the flags register. Ideas to fix this:
|
* PHP-8.1: Fixed GH-12382: JIT Index invalid or out of range error
* PHP-8.2: Fixed GH-12382: JIT Index invalid or out of range error
* PHP-8.3: Fixed GH-12382: JIT Index invalid or out of range error
Description
The following code: https://paste.daniil.it/BaconQrCode.tar.xz, which is https://github.com/Bacon/BaconQrCode/ with an additional unit test that reproduces the issue.
Ref Bacon/BaconQrCode#92
Resulted in this output:
But I expected this output instead: no failed tests.
PHP Version
#12381
Operating System
No response
The text was updated successfully, but these errors were encountered: