Skip to content

Some zvals are missing in memory dump for classes with the __debugInfo magic. #135

@vtsykun

Description

@vtsykun

STR

  1. Run script
<?php declare(strict_types=1);

namespace AAA;

unset($GLOBALS['_POST'], $GLOBALS['_COOKIE'], $GLOBALS['_FILES'], $GLOBALS['argv'], $GLOBALS['_GET'], $GLOBALS['_SERVER'], $GLOBALS['argc'], $GLOBALS['argv']);

class MTProtoBug
{
    private int $v = 1;
    private array $info = [];

    public function __debugInfo(): array
    {
        $vars = get_object_vars($this);
        unset($vars['info']);
        return $vars;
    }
}

$bug = new MTProtoBug();
\meminfo_dump(\fopen('/tmp/mem_dump.json', 'w'));

Actual result

{
  "header" : {
    "memory_usage" : 360456,
    "memory_usage_real" : 2097152,
    "peak_memory_usage" : 429360,
    "peak_memory_usage_real" : 2097152
  },
  "items": {
    "0x7fd6f746a140" : {
        "type" : "object",
        "size" : "72",
        "symbol_name" : "bug",
        "is_root" : true,
        "frame" : "<GLOBAL>",
        "class" : "AAA\\MTProtoBug",
        "object_handle" : "1",
        "children" : {
            "v":"0x7fd6f745ca40"
        }
    },
    "0x7fd6f745ca40" : {
        "type" : "int",
        "size" : "16",
        "is_root" : false
    }
}
}

Expect result

MTProtoBug->info must persist in the memory dump

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions