Bug #77257 [Opn]: value of variable assigned in a switch() construct gets lost
| From: | nikic@php.net | Date: | Mon, 10 Dec 2018 16:53:53 +0000 |
| Subject: | Bug #77257 [Opn]: value of variable assigned in a switch() construct gets lost | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218371@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77257&edit=1
ID: 77257
Updated by: nikic@php.net
Reported by: mail dot cmcm at gmail dot com
Summary: value of variable assigned in a switch() construct
gets lost
Status: Open
Type: Bug
Package: opcache
Operating System: Windows 10
PHP Version: 7.3.0
Block user comment: N
Private report: N
New Comment:
Okay, that was maybe a bit too reduced. A better variant is:
<?php
function test($x) {
$a = false;
switch($x["y"]) {
case "a":
$a = true;
break;
case "b":
break;
case "c":
break;
}
return $a;
}
var_dump(test(["y" => "a"]));
The issue is basically that we currently require that block predecessors are unique. The code for
unlinking a block has a broken implementation of the deduplication. However, the more important
issue is that if we remove predecessors due to deduplication, we must also adjust phi nodes
accordingly.
Those issues can be fixed, but I think that the cleaner fix would be to relax the restriction on
duplicate predecessors. Not sure what other fallout that would have though.
Previous Comments:
------------------------------------------------------------------------
[2018-12-10 15:53:45] nikic@php.net
Reduced test case based on code provided via mail:
function test($x) {
switch ($x["y"]) {
case "a":
break;
case "b":
break;
}
}
This generates "Block 4 predecessors missing 1" SSA verification errors, first appearing
after jump optimization.
------------------------------------------------------------------------
[2018-12-07 16:22:43] nikic@php.net
For this purpose it's usually enough to only have the function that contains the switch, even
if it cannot be run in isolation. The surrounding code (likely) does not matter. The code is only
needed to get an opcode dump and see the faulty transformation, a smaller test case can then be
reconstructed from there.
------------------------------------------------------------------------
[2018-12-07 12:17:08] mail dot cmcm at gmail dot com
I'm really sorry, but I can't. I'm working on a backend for a music publisher and
we're talking about a huge project. When I find the time I'll try again to reproduce the
problem outside this project. It doesn't happen if I isolate the method so it could be hard to
pinpoint... :(
------------------------------------------------------------------------
[2018-12-07 11:05:57] nikic@php.net
Can you please provide the (non-reduced) source code of the function that is failing? If you
can't publish the code, please feel free to mail to me directly at nikic@php.net.
------------------------------------------------------------------------
[2018-12-07 07:12:40] requinix@php.net
I doubt it's specific to Windows. Likely just a regular opcache bug.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=77257
--
Edit this bug report at https://bugs.php.net/bug.php?id=77257&edit=1