Skip to content
Open
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
2 changes: 1 addition & 1 deletion Zend/Optimizer/block_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ static zend_always_inline zend_basic_block *get_next_block(const zend_cfg *cfg,
}
next_block++;
}
while (next_block->len == 0 && !(next_block->flags & ZEND_BB_PROTECTED)) {
while (next_block->len == 0 && !(next_block->flags & (ZEND_BB_TARGET|ZEND_BB_PROTECTED))) {
Copy link
Member

@arnaud-lb arnaud-lb Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that stopping at ZEND_BB_TARGET will often disable this optimization, as next_block will be ZEND_BB_TARGET most of the time (since it's the next block after an unconditional JMP, it must be a jump target), and this causes target_block == next_block to be false when there where blocks to skip here.

Maybe only in master, but would it make sense to relax the rule JMPZ(X,L1) JMP(L2) L1: -> JMPNZ(X,L2) NOP to JMPZ(X,L1) JMP(L2) L3: -> JMPNZ(X,L2) NOP with L3 being either L1 itself or part of a chain of empty predecessors to L1?

Copy link
Member Author

@iluuu1994 iluuu1994 Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, it seems to affect only 5 of our tests. Another solution might be to immediately remove references to blocks when they become empty, and relink them to the following block, and remove ZEND_BB_TARGET from the empty block that will then be properly dead.

next_block = cfg->blocks + next_block->successors[0];
}
return next_block;
Expand Down
14 changes: 14 additions & 0 deletions ext/opcache/tests/oss-fuzz-472563272.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
OSS-Fuzz #472563272
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
--FILE--
<?php
false || (true ? true : false) || (false ? true : false) || true;
?>
===DONE===
--EXPECT--
===DONE===