View Issue Details

IDProjectCategoryView StatusLast Update
0002375XdebugUncategorizedpublic2025-10-24 21:02
Reporterderick Assigned Toderick  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version3.4.6 
Target Version3.4devFixed in Version3.4dev 
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.

Issue History

Date Modified Username Field Change
2025-10-24 13:34 derick New Issue
2025-10-24 13:46 derick Summary Xdebug's var_dump() initialises lazy objects => Xdebug's exception trace conversion initialises lazy objects
2025-10-24 13:46 derick Description Updated
2025-10-24 13:46 derick Steps to Reproduce Updated
2025-10-24 15:56 derick Note Added: 0007375
2025-10-24 16:15 derick Assigned To => derick
2025-10-24 16:15 derick Status new => closed
2025-10-24 16:15 derick Resolution open => fixed
2025-10-24 16:15 derick Fixed in Version => 3.4dev
2025-10-24 16:15 derick Note Added: 0007376
2025-10-24 21:02 HypeMC Note Added: 0007377