Bug #78341 [Asn->Csd]: Failure to detect smart branch in DFA pass
Edit report at https://bugs.php.net/bug.php?id=78341&edit=1
ID: 78341
Updated by: nikic@php.net
Reported by: jfcherng at gmail dot com
Summary: Failure to detect smart branch in DFA pass
-Status: Assigned
+Status: Closed
Type: Bug
Package: opcache
Operating System: Win7 x64
PHP Version: 7.3.8RC1
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8e63bb5e465620f27de93dea82e0d84be72da7f3
Log: Fixed bug #78341
Previous Comments:
------------------------------------------------------------------------
[2019-07-29 10:53:25] nikic@php.net
Here is a reproducer:
<?php
function test($a) {
// Just some dead code...
if (strpos("foo", "foo") !== 0) {
echo "Foo";
}
$x = $a === null;
if ($x) {
var_dump($x);
}
}
test(null);
------------------------------------------------------------------------
[2019-07-29 10:36:29] nikic@php.net
We're generating
#164.CV30($zvalIsRef) [bool] RANGE[0..1] = IS_NOT_IDENTICAL #162.V36 [any] null
JMPZ #164.CV30($zvalIsRef) [bool] RANGE[0..1] BB17
instead of
#164.CV30($zvalIsRef) [bool] RANGE[0..1] = IS_NOT_IDENTICAL #162.V36 [any] null
NOP
JMPZ #164.CV30($zvalIsRef) [bool] RANGE[0..1] BB17
------------------------------------------------------------------------
[2019-07-28 12:30:18] jfcherng at gmail dot com
Line 268: https://github.com/symfony/var-dumper/blob/v4.3.3/Cloner/VarCloner.php#L268
"zvalIsRef" is defined in: https://github.com/symfony/var-dumper/blob/v4.3.3/Cloner/VarCloner.php#L84-L89
------------------------------------------------------------------------
[2019-07-28 12:26:33] jfcherng at gmail dot com
Description:
------------
PHP 7.3.8RC1 (and 7.4snapshot) emits notices after I update symfony/var-dumper to v4.3.3 today.
"zvalIsRef in vendor\symfony\var-dumper\Cloner\VarCloner.php on line 268"
The variable "zvalIsRef" around VarCloner.php on line 268 is actually obviously defined.
So I have much confidence this is a PHP engine's problem.
After some tests, this seems to be the problematic commit https://github.com/php/php-src/commit/e7a83ec8dff962ea624508f18b9b10f5add030cc
. It's parent 3fa9f9cfae2cedd7b6d26b6487dd156321243ab7 works fine in my test.
I am sorry that I am not able to give a smaller test case.
Test script:
---------------
<?php
declare(strict_types=1);
// remember to set opcache.enable_cli=1 if this test is done in cli
// composer require symfony/var-dumper:v4.3.3
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\VarDumper\Cloner\VarCloner;
$myVar = new ArrayObject();
$cloner = new VarCloner();
$data = $cloner->cloneVar($myVar);
Expected result:
----------------
no notice is emitted.
Actual result:
--------------
Notice: Undefined variable: zvalIsRef in vendor\symfony\var-dumper\Cloner\VarCloner.php on line 268
Notice: Undefined variable: zvalIsRef in vendor\symfony\var-dumper\Cloner\VarCloner.php on line 268
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78341&edit=1
Thread (5 messages)