php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79860 Misoptimization under preloading
Submitted: 2020-07-14 15:00 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: nikic@php.net Assigned:
Status: Open Package: opcache
PHP Version: 7.4.8 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2020-07-14 15:00 UTC] nikic@php.net
Description:
------------
Test case gets misoptimized under preloading, because the optimization pipeline runs twice. This happens during the second run of pass 9 (tmpvars):

$_main:
     ; (lines=27, args=0, vars=6, tmps=5)
     ; (after pass 5)
     ; /home/nikic/php/php-src/t049.php:1-10
     ; return  [] RANGE[0..0]
0000 ASSIGN CV0($multi) array(...)
0001 V6 = FE_RESET_R CV0($multi) 0025
0002 T7 = FE_FETCH_R V6 V8 0025
0003 V9 = FETCH_LIST_R V8 int(0)
0004 V10 = FETCH_LIST_R V9 int(0)
0005 ASSIGN CV1($a) V10
0006 V10 = FETCH_LIST_R V9 int(1)
0007 ASSIGN CV2($b) V10
0008 FREE V9
0009 V9 = FETCH_LIST_R V8 int(1)
0010 V10 = FETCH_LIST_R V9 int(0)
0011 ASSIGN CV3($c) V10
0012 V10 = FETCH_LIST_R V9 int(1)
0013 ASSIGN CV4($d) V10
0014 FREE V9
0015 FREE V8
0016 ASSIGN CV5($key) T7
0017 INIT_FCALL 1 96 string("var_dump")
0018 T8 = CONCAT CV5($key) CV1($a)
0019 T7 = CONCAT T8 CV2($b)
0020 T8 = CONCAT T7 CV3($c)
0021 T7 = CONCAT T8 CV4($d)
0022 SEND_VAL T7 1
0023 DO_ICALL
0024 JMP 0002
0025 FE_FREE V6
0026 RETURN int(1)

$_main:     
     ; (lines=27, args=0, vars=6, tmps=4)
     ; (after pass 9)
     ; /home/nikic/php/php-src/t049.php:1-10
     ; return  [] RANGE[0..0]
0000 ASSIGN CV0($multi) array(...)
0001 V6 = FE_RESET_R CV0($multi) 0025
0002 T7 = FE_FETCH_R V6 V8 0025
0003 V8 = FETCH_LIST_R V8 int(0)
0004 V9 = FETCH_LIST_R V8 int(0)
0005 ASSIGN CV1($a) V9
0006 V9 = FETCH_LIST_R V8 int(1)
0007 ASSIGN CV2($b) V9
0008 FREE V8
0009 V8 = FETCH_LIST_R V8 int(1)
0010 V9 = FETCH_LIST_R V8 int(0)
0011 ASSIGN CV3($c) V9
0012 V9 = FETCH_LIST_R V8 int(1)
0013 ASSIGN CV4($d) V9
0014 FREE V8
0015 FREE V8
0016 ASSIGN CV5($key) T7
0017 INIT_FCALL 1 96 string("var_dump")
0018 T8 = CONCAT CV5($key) CV1($a)
0019 T7 = CONCAT T8 CV2($b)
0020 T8 = CONCAT T7 CV3($c)
0021 T7 = CONCAT T8 CV4($d)
0022 SEND_VAL T7 1
0023 DO_ICALL
0024 JMP 0002
0025 FE_FREE V6
0026 RETURN int(1)


Test script:
---------------
<?php

$multi = array(
    array(array(1,2), array(3,4)),
);

foreach ($multi as list(list($a, $b), list($c, $d))) {
    var_dump($a . $b . $c . $d);
}


Expected result:
----------------
string(4) "1234"


Actual result:
--------------
string(2) "12"


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Oct 26 05:01:24 2020 UTC