View Issue Details

IDProjectCategoryView StatusLast Update
0002287XdebugUncategorizedpublic2024-11-27 15:55
Reporterbkdotcom Assigned Toderick  
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionno change required 
PlatformXdebug v3.4.0alpha2-deOSOSXOS Version12.7.6
Summary0002287: zend_mm_heap corrupted in develop mode
Description

Reflecting a class containing new php 8.4 features (property hooks / asymmetric-visibility) with xdebug.mode = develop leads to

zend_mm_heap corrupted
Abort trap: 6

Steps To Reproduce
<?php

/**
 * PHP 8.4 property hooks & asymmetric visibility
 */
class NewFeatures
{
    public protected(set) ?string $name;
    protected private(set) ?int $age;

    // public static array $static = [];

    public ?string $backedGetOnly {
        get => $this->backedGetOnly;
    }

    public ?string $backedSetOnly {
        set (?string $value) {
            $this->backedSetOnly = $value;
        }
    }

    public ?string $backedGetAndSet {
        set (?string $value) {
            $this->backedGetAndSet = $value;
        }

        get => $this->backedGetAndSet;
    }

    public $things = [];

    public string $virtualGetOnly {
        get => \implode(', ', $this->things);
    }

    public string $virtualSetOnly {
        set (string $value) {
            $this->things[] = $value;
        }
    }

    public string $virtualGetAndSet {
        set (string $value) {
            $this->things[] = $value;
        }

        get => \implode(', ', $this->things);
    }
}

$newFeatures = new NewFeatures();

$refObj = new ReflectionObject($newFeatures);
$refProps = $refObj->getProperties();

foreach ($refProps as $refProp) {
    propInfo($refProp, $newFeatures);
}

echo 'the end' . "\n\n";

function propInfo(ReflectionProperty $refProperty, $obj)
{
    $info = array(
        'hooks' => \array_keys($refProperty->getHooks()),
        'isVirtual' => $refProperty->isVirtual(), // at least one hook and none of the hooks reference the property
        'value' => null,
    );
    $isWriteOnly = $info['isVirtual'] && \in_array('get', $info['hooks'], true) === false;
    if ($isWriteOnly) {
        return;
    }
    $refProperty->setAccessible(true);
    if ($refProperty->isInitialized($obj)) {
        try {
            $info['value'] = $refProperty->isStatic() === false && $refProperty->isVirtual() === false
                ? $refProperty->getRawValue($obj)
                : $refProperty->getValue($obj);
        } catch (\Error $e) {
            echo 'Error: ' . $e->getMessage() . "\n";
        }
    }
}
Additional Information

commenting out any one of the properties and the script will complete... some sort of internal buffer issue?!

TagsNo tags attached.
Operating Systemosx
PHP Version8.4-dev

Activities

bkdotcom

2024-09-06 13:21

reporter   ~0007050

sorry about the formatting... I don't see and option to fix/edit it :|

derick

2024-10-04 14:33

administrator   ~0007053

Attachment for reproducing script.

2287.php (2,036 bytes)   
<?php

/**
 * PHP 8.4 property hooks & asymmetric visibility
 */
class NewFeatures
{
    public protected(set) ?string $name;
    protected private(set) ?int $age;

    // public static array $static = [];

    public ?string $backedGetOnly {
        get => $this->backedGetOnly;
    }

    public ?string $backedSetOnly {
        set (?string $value) {
            $this->backedSetOnly = $value;
        }
    }

    public ?string $backedGetAndSet {
        set (?string $value) {
            $this->backedGetAndSet = $value;
        }

        get => $this->backedGetAndSet;
    }

    public $things = [];

    public string $virtualGetOnly {
        get => \implode(', ', $this->things);
    }

    public string $virtualSetOnly {
        set (string $value) {
            $this->things[] = $value;
        }
    }

    public string $virtualGetAndSet {
        set (string $value) {
            $this->things[] = $value;
        }

        get => \implode(', ', $this->things);
    }
}

$newFeatures = new NewFeatures();

$refObj = new ReflectionObject($newFeatures);
$refProps = $refObj->getProperties();

foreach ($refProps as $refProp) {
    propInfo($refProp, $newFeatures);
}

echo 'the end' . "\n\n";

function propInfo(ReflectionProperty $refProperty, $obj)
{
    $info = array(
        'hooks' => \array_keys($refProperty->getHooks()),
        'isVirtual' => $refProperty->isVirtual(), // at least one hook and none of the hooks reference the property
        'value' => null,
    );
    $isWriteOnly = $info['isVirtual'] && \in_array('get', $info['hooks'], true) === false;
    if ($isWriteOnly) {
        return;
    }
    $refProperty->setAccessible(true);
    if ($refProperty->isInitialized($obj)) {
        try {
            $info['value'] = $refProperty->isStatic() === false && $refProperty->isVirtual() === false
                ? $refProperty->getRawValue($obj)
                : $refProperty->getValue($obj);
        } catch (\Error $e) {
            echo 'Error: ' . $e->getMessage() . "\n";
        }
    }
}
2287.php (2,036 bytes)   

derick

2024-10-08 15:26

administrator   ~0007066

I didn't manage to reproduce this. Can you share the output of xdebug_info()?

bkdotcom

2024-10-13 19:56

reporter   ~0007076

xdebug_info output attached

xdebug_info.txt (3,914 bytes)   
__   __   _      _                 
\ \ / /  | |    | |                
 \ V / __| | ___| |__  _   _  __ _ 
  > < / _` |/ _ \ '_ \| | | |/ _` |
 / . \ (_| |  __/ |_) | |_| | (_| |
/_/ \_\__,_|\___|_.__/ \__,_|\__, |
                              __/ |
                             |___/ 

Version => 3.4.0alpha2-dev
Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support

             Enabled Features (through 'xdebug.mode' setting)             
Feature => Enabled/Disabled
Development Helpers => ✔ enabled
Coverage => ✔ enabled
GC Stats => ✘ disabled
Profiler => ✘ disabled
Step Debugger => ✔ enabled
Tracing => ✘ disabled

                            Optional Features                            
Compressed File Support => yes (gzip)
Clock Source => clock_gettime_nsec_np
'xdebug://gateway' pseudo-host support => no
'xdebug://nameserver' pseudo-host support => no
Systemd Private Temp Directory => not enabled

                              Diagnostic Log                              
No messages

                              Step Debugging                              
Debugger is not active

                                   PHP                                   
                           Build Configuration                           
Version (Run Time) => 8.4.0-dev
Version (Compile Time) => 8.4.0-dev
Debug Build => no
Thread Safety => disabled
                                 Settings                                 
Configuration File (php.ini) Path => /usr/local/etc/php/8.4
Loaded Configuration File => /usr/local/etc/php/8.4/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/8.4/conf.d
Additional .ini files parsed => /usr/local/etc/php/8.4/conf.d/20-xdebug.ini,
/usr/local/etc/php/8.4/conf.d/ext-opcache.ini


Directive => Local Value => Master Value
xdebug.mode => debug,coverage,develop => debug,coverage,develop
xdebug.start_with_request => trigger => trigger
xdebug.start_upon_error => default => default
xdebug.output_dir => /var/tmp/ => /var/tmp/
xdebug.use_compression => 1 => 1
xdebug.trigger_value => no value => no value
xdebug.file_link_format => no value => no value
xdebug.filename_format => no value => no value
xdebug.log => no value => no value
xdebug.log_level => 7 => 7
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3
xdebug.max_nesting_level => 512 => 512
xdebug.cli_color => 0 => 0
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.halt_level => 0 => 0
xdebug.max_stack_frames => -1 => -1
xdebug.show_error_trace => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_globals => On => On
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.profiler_append => Off => Off
xdebug.cloud_id => no value => no value
xdebug.client_host => 127.0.0.1 => 127.0.0.1
xdebug.client_port => 9000 => 9000
xdebug.discover_client_host => Off => Off
xdebug.client_discovery_header => HTTP_X_FORWARDED_FOR,REMOTE_ADDR => HTTP_X_FORWARDED_FOR,REMOTE_ADDR
xdebug.idekey => no value => no value
xdebug.connect_timeout_ms => 200 => 200
xdebug.scream => Off => Off
xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.collect_assignments => Off => Off
xdebug.collect_params => On => On
xdebug.collect_return => Off => Off
xdebug_info.txt (3,914 bytes)   

derick

2024-10-16 16:22

administrator   ~0007077

Hi,

I've tried it again, with the exact same settings as you have, but no success in reproducing this. Can you try Xdebug 3.4.0beta1 perhaps?

cheers,
Derick

bkdotcom

2024-10-18 01:15

reporter   ~0007078

CAN BE CLOSED

Working for me now (more recent php 8.4 build)

php -v
PHP 8.4.0-dev (cli) (built: Oct 18 2024 00:15:08) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.0-dev, Copyright (c) Zend Technologies
with Xdebug v3.4.0alpha2-dev, Copyright (c) 2002-2024, by Derick Rethans

Thank you for your time!
with Zend OPcache v8.4.0-dev, Copyright (c), by Zend Technologies

derick

2024-11-27 15:55

administrator   ~0007089

Thanks for letting me know. If it returns with Xdebug 3.4.0 (out soon), then please open a new ticket!

cheers,
Derick

Issue History

Date Modified Username Field Change
2024-09-05 21:04 bkdotcom New Issue
2024-09-06 13:21 bkdotcom Note Added: 0007050
2024-10-04 14:32 derick Steps to Reproduce Updated
2024-10-04 14:33 derick Note Added: 0007053
2024-10-04 14:33 derick File Added: 2287.php
2024-10-08 15:26 derick Assigned To => derick
2024-10-08 15:26 derick Status new => feedback
2024-10-08 15:26 derick Note Added: 0007066
2024-10-13 19:56 bkdotcom Note Added: 0007076
2024-10-13 19:56 bkdotcom File Added: xdebug_info.txt
2024-10-13 19:56 bkdotcom Status feedback => assigned
2024-10-16 16:22 derick Status assigned => feedback
2024-10-16 16:22 derick Note Added: 0007077
2024-10-18 01:15 bkdotcom Note Added: 0007078
2024-10-18 01:15 bkdotcom Status feedback => assigned
2024-11-27 15:55 derick Status assigned => resolved
2024-11-27 15:55 derick Resolution open => no change required
2024-11-27 15:55 derick Note Added: 0007089