[php-src] PR #25244: Fix overflow in optimizer block-pass complexity guard
| From: | joshtrichards | Date: | Fri, 06 Nov 2026 16:33:20 +0000 |
| Subject: | [php-src] PR #25244: Fix overflow in optimizer block-pass complexity guard | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40358@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25244
Author: joshtrichards
The block-pass complexity guard multiplies the basic-block count by the variable count using 32-bit
unsigned arithmetic. For sufficiently large functions, the product can wrap below the 64M threshold
and bypass the guard.
The guard was introduced for [Bug #74250](https://bugs.php.net/bug.php?id=74250) via commit 7ea2616
to skip expensive block-pass optimization of large functions. Overflow can defeat that safeguard and
potentially cause excessive compilation latency.
Changes:
- Widen the variable-count addition to
uint64_t and compare against the threshold
divided by the block count. This avoids addition and multiplication overflow while preserving the
exact threshold and zero-block behavior. The division uses 32-bit operands on both 32-bit and 64-bit
targets.