Skip to content

Commit cd49db9

Browse files
committed
Fixed bug #77266 (Assertion failed in dce_live_ranges)
1 parent 76c687f commit cd49db9

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ PHP NEWS
4343
no external visibility). (Anatol)
4444

4545
- Opcache:
46+
. Fixed bug #77266 (Assertion failed in dce_live_ranges). (Laruence)
4647
. Fixed bug #77257 (value of variable assigned in a switch() construct gets
4748
lost). (Nikita)
4849

ext/opcache/Optimizer/zend_optimizer.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,39 @@ void zend_optimizer_remove_live_range(zend_op_array *op_array, uint32_t var)
621621
}
622622
}
623623

624+
static uint32_t zend_determine_constructor_call(zend_op_array *op_array, uint32_t start) {
625+
int call = 0;
626+
while (start++ < op_array->last) {
627+
switch (op_array->opcodes[start].opcode) {
628+
case ZEND_INIT_FCALL_BY_NAME:
629+
case ZEND_INIT_NS_FCALL_BY_NAME:
630+
case ZEND_INIT_STATIC_METHOD_CALL:
631+
case ZEND_INIT_METHOD_CALL:
632+
case ZEND_INIT_FCALL:
633+
case ZEND_NEW:
634+
case ZEND_INIT_DYNAMIC_CALL:
635+
case ZEND_INIT_USER_CALL:
636+
call++;
637+
break;
638+
case ZEND_DO_FCALL:
639+
if (call == 0) {
640+
return start;
641+
}
642+
/* break missing intentionally */
643+
case ZEND_DO_ICALL:
644+
case ZEND_DO_UCALL:
645+
case ZEND_DO_FCALL_BY_NAME:
646+
call--;
647+
break;
648+
default:
649+
break;
650+
}
651+
}
652+
653+
ZEND_ASSERT(0);
654+
return -1;
655+
}
656+
624657
void zend_optimizer_remove_live_range_ex(zend_op_array *op_array, uint32_t var, uint32_t start)
625658
{
626659
uint32_t i = 0;
@@ -638,7 +671,12 @@ void zend_optimizer_remove_live_range_ex(zend_op_array *op_array, uint32_t var,
638671
case ZEND_FE_RESET_R:
639672
case ZEND_FE_RESET_RW:
640673
var |= ZEND_LIVE_LOOP;
641-
/* break missing intentionally */
674+
start++;
675+
break;
676+
case ZEND_NEW:
677+
start = zend_determine_constructor_call(op_array, start);
678+
start++;
679+
break;
642680
default:
643681
start++;
644682
}

ext/opcache/tests/bug77266.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #77266 (Assertion failed in dce_live_ranges)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
final class Lock
12+
{
13+
private static function clearOrphanedLocks()
14+
{
15+
$lockList = [];
16+
17+
$serverMonitors = array();
18+
$listCount = count($lockList);
19+
if ( is_array($lockList) && $listCount > 0 ) {
20+
$v = explode(':', $value);
21+
if (!$serverMonitors[$v[0]]['m']) {
22+
$serverMonitors[$v[0]]['m'] = new ServerMonitor($v[0]);
23+
}
24+
25+
}
26+
27+
}
28+
29+
}
30+
?>
31+
okey
32+
--EXPECT--
33+
okey

0 commit comments

Comments
 (0)