View Issue Details

IDProjectCategoryView StatusLast Update
0001665XdebugRemote Debuggingpublic2019-09-06 11:10
ReporterXenosAssigned Toderick 
PriorityhighSeverityblockReproducibilityalways
Status closedResolutionfixed 
Product Version 
Target Version2.8.0devFixed in Version2.8.0dev 
Summary0001665: Segfault when overriding a function object parameter + collect_params > 0
DescriptionHi,

The remote debug functionnality of XDebug crashs (segfault 11) in the provided example, whith collect_params = 0

I will give a look at xdebug code and try to fix this issue, but I want to report it so you can try to reproduce the issue too. I suspect some other segfault tickets are duplicates of this one, but I'm providing lightest test case I could find

Steps To Reproduce
function query($var) {
    try {
        $var = "Country rooooads"; // Rewriting an object var segfaults
        throw new LogicException('I am broken');
    } catch (Exception $ex) {
        var_dump(time() . ': Segfault did not happened');
    }
}

query(new stdClass());


Running this on XDebug 2.6.1 (PHP 7.1.16 Windows) or 2.7.0 (php 7.3.3 Windows or Linux) with the option "xdebug.collect_params > 0" (ie 1, 2, 3 etc) generates a segfault.

With collect_params = 0, there is no segfault
Additional InformationWhen we don't override the value of the $var object parameter, then there is *no* segfault
function query($var) {
    try {
        throw new LogicException('I am broken');
    } catch (Exception $ex) {
        var_dump(time() . ': Segfault did not happened');
    }
}

query(new stdClass());


When overriding the value with another object (instead of a scalar) there *is* a segfault:
function query($var) {
    try {
        $var = (object)(array('x' => 1)); // Rewriting an object var segfaults
        throw new LogicException('I am broken');
    } catch (Exception $ex) {
        var_dump(time() . ': Segfault did not happened');
    }
}

query(new stdClass());


When not using a function like below, there is *no* segfault

$var = new stdClass();
try {
    $var = "Country rooooads bis"; // Rewriting an object var segfaults
    throw new LogicException('I am broken');
} catch (Exception $ex) {
    var_dump(time() . ': Segfault did not happened');
}


When using an array, there is *no* segfault:
//... same function
query(array(1,2,3));


When using a scalar, there is *no* segfault either:
//... same function
query(123);


TagsNo tags attached.
Operating System
PHP Version7.3.0-7.3.1

Relationships

has duplicate 0001535 resolvedderick Laravel causes PHP warning (exception not caught) xdebug enabled, otherwise all is fine 
has duplicate 0001651 resolvedderick segfault in xdebug_var_export with collect_params set to 3 or 4 

Activities

Xenos

2019-05-13 15:15

reporter   ~0005021

Note that the segfault can be triggered from command line (using the
php -f testcase.php
command) so no need for Apache, PDO, whatever

Xenos

2019-05-15 13:59

reporter   ~0005022

I've made a (very messy) pull request addressing that https://github.com/xdebug/xdebug/pull/472

Once I make it work on PHP 7/7.1/7.2 (tests seems to fail because of GC_DELREF), I'll close it, and reopen it following properly the "contribute" guidelines (issue1665 branch name, forking xdebug_2_7, and with a single commit instead of 6-7 because I was afraid of loosing things by accident : ) )

derick

2019-09-06 11:10

administrator   ~0005134

This has been fixed for Xdebug 2.8-dev (likely to become 2.8.0RC1). Thanks for the initial PR and test cases!

Issue History

Date Modified Username Field Change
2019-05-13 14:01 Xenos New Issue
2019-05-13 15:15 Xenos Note Added: 0005021
2019-05-15 13:59 Xenos Note Added: 0005022
2019-06-28 11:15 derick Status new => confirmed
2019-06-28 11:15 derick Product Version 2.7.0 => 2.8.0dev
2019-06-28 11:15 derick Product Version 2.8.0dev =>
2019-06-28 11:15 derick Target Version => 2.8.0dev
2019-06-28 11:18 derick Relationship added has duplicate 0001535
2019-06-28 11:50 derick Relationship added has duplicate 0001651
2019-09-06 11:10 derick Assigned To => derick
2019-09-06 11:10 derick Status confirmed => closed
2019-09-06 11:10 derick Resolution open => fixed
2019-09-06 11:10 derick Fixed in Version => 2.8.0dev
2019-09-06 11:10 derick Note Added: 0005134