Repository navigation
Conversation
…ions in function JIT `range->var` is a byte offset, but `var_num` is an index, so we have to convert the index to the byte offset using `EX_NUM_TO_VAR()`. This matches `cleanup_live_vars()` code.
jorgsowa
approved these changes
Oct 30, 2026
Comment on lines
+12
to
+34
| <?php | ||
|
|
||
| function deep(int $a, int $b, int $c) { | ||
| $a &= 255; | ||
| return ($a + 1) - ($b + $b + (($a + 1) % ($b % $c))); | ||
| } | ||
|
|
||
| $out = [deep(15, 3, 7)]; | ||
| try { | ||
| deep(15, 3, 0); | ||
| } catch (DivisionByZeroError $e) { | ||
| $out[] = $e->getMessage(); | ||
| } | ||
| var_dump($out); | ||
|
|
||
| ?> | ||
| --EXPECT-- | ||
| array(2) { | ||
| [0]=> | ||
| int(9) | ||
| [1]=> | ||
| string(14) "Modulo by zero" | ||
| } |
Contributor
There was a problem hiding this comment.
<?php
class D {
function self() { return $this; }
function __destruct() { echo "dtor\n"; }
}
// Leaves a stale object in the frame slot deep() uses for its first temporary
function pollute($a, $b, $c) {
return $a->self()->self();
}
function deep(int $a, int $b, int $c) {
$a &= 255;
return ($a + 1) - ($b + $b + (($a + 1) % ($b % $c)));
}
$o = new D;
var_dump(deep(15, 3, 7));
pollute($o, 1, 2);
try {
deep(15, 3, 0);
} catch (DivisionByZeroError $e) {
echo $e->getMessage(), "\n";
}
echo "end\n";
?>
--EXPECT--
int(9)
Modulo by zero
end
dtor
Such test fails without ASan enabled.
iliaal
approved these changes
Oct 31, 2026
iliaal
left a comment
Member
There was a problem hiding this comment.
The tracing JIT's version of this check compares opline->result.var, already a byte offset, so only this site needed the conversion. +1 to jorgsowa's test: the current one passes without the fix on a non-ASan debug build, while the proposed one fails there and passes with it.
Co-authored-by: Jorg Sowa <jorg.sowa@gmail.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
range->varis a byte offset, butvar_numis an index, so we have to convert the index to the byte offset usingEX_NUM_TO_VAR(). This matchescleanup_live_vars()code.