Repository navigation
Commit dd57dde
committed
Fix block pass dropping a JMP across an unreachable_free block
An unreachable block that frees a loop variable created in a reachable block is
marked ZEND_BB_UNREACHABLE_FREE and is still emitted, because the FREE opcodes
it contains determine where the live range of that variable ends. Two places
that decide whether a ZEND_JMP can be dropped because it targets the block that
physically follows skipped over every block that is not ZEND_BB_REACHABLE,
including those.
The jump was therefore removed even though an unreachable_free block still sat
between the two, and control fell straight into a FREE opcode that was never
meant to be executed:
function test($a, $b, $c) {
do {
if ($a) {
switch ($b[0]) {
case 'x':
switch ($c[0]) {
default:
return "returned";
}
default:
continue 2;
}
}
} while (false);
return $b[0];
}
Taking the "continue 2" path freed the switch subject twice, and the resulting
live range was inverted, which also tripped the start < end assertion in
emit_live_range_raw().
Assisted-By: Claude Opus 5 <noreply@anthropic.com>1 parent e832b5e commit dd57dde
3 files changed
Lines changed: 56 additions & 1 deletion
File tree
- Zend/Optimizer
- ext/opcache/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
950 | 950 | | |
951 | 951 | | |
952 | 952 | | |
953 | | - | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
954 | 959 | | |
955 | 960 | | |
956 | 961 | | |
| |||
1149 | 1154 | | |
1150 | 1155 | | |
1151 | 1156 | | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
1152 | 1162 | | |
1153 | 1163 | | |
1154 | 1164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
0 commit comments