php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78341 Failure to detect smart branch in DFA pass
Submitted: 2019-07-28 12:26 UTC Modified: 2019-07-29 11:00 UTC
From: jfcherng at gmail dot com Assigned: nikic (profile)
Status: Closed Package: opcache
PHP Version: 7.3.8RC1 OS: Win7 x64
Private report: No CVE-ID: None
 [2019-07-28 12:26 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-07-29 10:36 UTC] nikic@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: nikic
 [2019-07-29 10:36 UTC] 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-29 10:53 UTC] 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 11:00 UTC] nikic@php.net
-Summary: Opcache DFA pass over-optimized? +Summary: Failure to detect smart branch in DFA pass
 [2019-07-29 11:04 UTC] nikic@php.net
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
 [2019-07-29 11:04 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 [2019-07-29 12:45 UTC] cmb@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d561a998c9313749ad2b488685e5c2bec661bc69
Log: Fixed bug #78341
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 07:01:23 2019 UTC