View Issue Details

IDProjectCategoryView StatusLast Update
0002375XdebugUncategorizedpublic2025-10-26 13:36
Reporterderick Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version3.4.6 
Target Version3.4devFixed in Version3.4.7 
Summary0002375: Xdebug's exception trace conversion initialises lazy objects
Description

When Xdebug is loaded, and a lazy object is in scope when an exception is triggered, the object gets unlazied.

Steps To Reproduce

Run the following script:

<?php

class Example
{
    private int $prop;

    public function getProp(): int 
    {   
        return $this->prop;
    }   
}

$refClass = new ReflectionClass(Example::class);

$object = $refClass->newLazyGhost(function ($object) {
    echo "Initializer called\n";
    $ref = new ReflectionObject($object);
    $p = $ref->getProperty('prop');
    $p->setValue($object, 1); 
});

function foo(object $object)
{
    try {
        throw new Exception();
    } catch (Exception $e) {
    }   
}

echo __FILE__, ':', __LINE__, "\n";
foo($object);

echo __FILE__, ':', __LINE__, "\n";
$object->getProp();

echo __FILE__, ':', __LINE__, "\n";
print_r((array) $object); // When Xdebug is loaded, the array is empty.

echo __FILE__, ':', __LINE__, "\n";

This should not output an empty array in the last var_dump.

TagsNo tags attached.
Operating System
PHP Version8.4.10-8.4.19

Activities

derick

2025-10-24 15:56

administrator   ~0007375

https://github.com/xdebug/xdebug/pull/1042

derick

2025-10-24 16:15

administrator   ~0007376

Fixed in Git now too.

HypeMC

2025-10-24 21:02

reporter   ~0007377

@derick Thank you, I can confirm this fixes my problem.