BitOne / php-meminfo

PHP extension to get insight about memory usage
MIT License
1.08k stars 78 forks source link

Duplication of scalar with multiple references on PHP7 #70

Closed BitOne closed 6 years ago

BitOne commented 6 years ago

With the following code:

<?php
unset($_GET);
unset($_FILES);
unset($_POST);
unset($_SERVER);
unset($_COOKIE);
unset($argv);
unset($argc);

$a = "test";

$b =& $a;

$c = strlen($b);

meminfo_dump(fopen('php://stdout', 'w'));

With PHP7, wrong output: b shouldn't be there, as it's a reference to a. And a has type unknown.

"items": {
    "0x7fb93bc571e0" : {
        "type" : "unknown",
        "size" : "16",
        "symbol_name" : "a",
        "is_root" : true,
        "frame" : "<GLOBAL>"
    },
    "0x7fb93bc57200" : {
        "type" : "unknown",
        "size" : "16",
        "symbol_name" : "b",
        "is_root" : true,
        "frame" : "<GLOBAL>"
    },
    "0x7fb93bc57220" : {
        "type" : "integer",
        "size" : "16",
        "symbol_name" : "c",
        "is_root" : true,
        "frame" : "<GLOBAL>"
    }
}

With PHP5, the output is correct:

{
"items": {
    "0x7f96977ad158" : {
        "type" : "string",
        "size" : "28",
        "symbol_name" : "a",
        "is_root" : true,
        "frame" : "<GLOBAL>"
    },
    "0x7f96977ad0f8" : {
        "type" : "integer",
        "size" : "24",
        "symbol_name" : "c",
        "is_root" : true,
        "frame" : "<GLOBAL>"
    }
}