View Issue Details

IDProjectCategoryView StatusLast Update
0002350XdebugStacktracespublic2025-05-22 13:07
Reporterf.bosch@genkgo.nl Assigned Toderick  
PrioritynormalSeveritymajorReproducibilityalways
Status assignedResolutionopen 
PlatformDockerOSAlpineOS Version3.20.6
Product Version3.4.2 
Summary0002350: [3.4.3] Crash when a certain page generates an exception
Description

A certain page generates an exception and that causes Xdebug to crash, resulting in a 502 Bad Gateway. I am on Xdebug 3.4.3 by the way, could only pick 3.4.2 from the list. This is the stacktrace.

warning: 29 src/thread/x86_64/syscall_cp.s: No such file or directory
(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
zval_addref_p (pz=0x719eb6e65978) at /usr/local/include/php/Zend/zend_types.h:1373
1373        return GC_ADDREF(Z_COUNTED_P(pz));
(gdb) bt full
#0  zval_addref_p (pz=0x719eb6e65978) at /usr/local/include/php/Zend/zend_types.h:1373
No locals.
#1  zval_from_stack_add_frame_variables (opa=0x43e3bce8, symbols=<optimized out>, edata=0x719eb6e658f8, frame=0x719ebba71520) at /tmp/pear/temp/xdebug/src/develop/stack.c:438
        symbol_name = 0x719eb6181960
        symbol = 0x719eb6e65978
        j = 3
        variables = {value = {lval = 124926488575712, dval = 6.1721886260838257e-310, counted = 0x719eb6f97ee0, str = 0x719eb6f97ee0, arr = 0x719eb6f97ee0, obj = 0x719eb6f97ee0, res = 0x719eb6f97ee0, ref = 0x719eb6f97ee0, ast = 0x719eb6f97ee0, 
            zv = 0x719eb6f97ee0, ptr = 0x719eb6f97ee0, ce = 0x719eb6f97ee0, func = 0x719eb6f97ee0, ww = {w1 = 3069804256, w2 = 29086}}, u1 = {type_info = 775, v = {type = 7 '\a', type_flags = 3 '\003', u = {extra = 0}}}, u2 = {next = 1922772230, 
            cache_slot = 1922772230, opline_num = 1922772230, lineno = 1922772230, num_args = 1922772230, fe_pos = 1922772230, fe_iter_idx = 1922772230, guard = 1922772230, constant_flags = 1922772230, extra = 1922772230}}
        j = <optimized out>
        variables = <optimized out>
        __arr = <optimized out>
        __z = <optimized out>
        symbol_name = <optimized out>
        symbol = <optimized out>
#2  zval_from_stack_add_frame (output=0x719ebbcbb4b0 <xdebug_globals+1104>, fse=0x719eb7216f90, edata=0x719eb6e658f8, add_local_vars=true, params_as_values=<optimized out>) at /tmp/pear/temp/xdebug/src/develop/stack.c:468
        frame = <optimized out>
#3  0x0000719ebbc98adf in zval_from_stack (output=output@entry=0x719ebbcbb4b0 <xdebug_globals+1104>, add_local_vars=add_local_vars@entry=true, params_as_values=params_as_values@entry=true) at /tmp/pear/temp/xdebug/src/develop/stack.c:496
        fse = 0x719eb7216f90
        next_fse = 0x719eb7217080
        i = 61
#4  0x0000719ebbc9ae23 in xdebug_develop_throw_exception_hook (exception=exception@entry=0x719eb6bfedc0, file=file@entry=0x719eb6bfee18, line=line@entry=0x719eb6bfee28, code=code@entry=0x719eb6bfee08, code_str=code_str@entry=0x0, 
    message=message@entry=0x719eb6bfede8) at /tmp/pear/temp/xdebug/src/develop/stack.c:1253
        exception_ce = 0x719eb7d07000
        exception_trace = <optimized out>
        tmp_str = {l = 488529, a = 491105, 
          d = 0x719eb605c280 "<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> InvalidArgumentException: Cannot find key country in /mnt/a"...}
        z_previous_exception = <optimized out>
        z_last_exception_slot = <optimized out>
        z_previous_trace = <optimized out>
        previous_exception_obj = <optimized out>
        dummy = {value = {lval = 9223372033224077936, dval = nan(0xfffff2797f270), counted = 0x7fffffff2797f270, str = 0x7fffffff2797f270, arr = 0x7fffffff2797f270, obj = 0x7fffffff2797f270, res = 0x7fffffff2797f270, ref = 0x7fffffff2797f270, 
            ast = 0x7fffffff2797f270, zv = 0x7fffffff2797f270, ptr = 0x7fffffff2797f270, ce = 0x7fffffff2797f270, func = 0x7fffffff2797f270, ww = {w1 = 664269424, w2 = 2147483647}}, u1 = {type_info = 3053134304, v = {type = 224 '\340', 
              type_flags = 33 '!', u = {extra = 46587}}}, u2 = {next = 29086, cache_slot = 29086, opline_num = 29086, lineno = 29086, num_args = 29086, fe_pos = 29086, fe_iter_idx = 29086, guard = 29086, constant_flags = 29086, extra = 29086}}
#5  0x0000719ebbc720b7 in xdebug_throw_exception_hook (exception=0x719eb6bfedc0) at /tmp/pear/temp/xdebug/src/base/base.c:1564
        code = 0x719eb6bfee08
        message = 0x719eb6bfede8
        file = 0x719eb6bfee18
        line = 0x719eb6bfee28
        exception_ce = <optimized out>
        code_str = 0x0
        dummy = {value = {lval = 124926566698304, dval = 6.1721924858527129e-310, counted = 0x719ebba18d40, str = 0x719ebba18d40, arr = 0x719ebba18d40, obj = 0x719ebba18d40, res = 0x719ebba18d40, ref = 0x719ebba18d40, ast = 0x719ebba18d40, 
            zv = 0x719ebba18d40, ptr = 0x719ebba18d40, ce = 0x719ebba18d40, func = 0x719ebba18d40, ww = {w1 = 3147926848, w2 = 29086}}, u1 = {type_info = 4074818590, v = {type = 30 '\036', type_flags = 204 '\314', u = {extra = 62176}}}, u2 = {
            next = 25858, cache_slot = 25858, opline_num = 25858, lineno = 25858, num_args = 25858, fe_pos = 25858, fe_iter_idx = 25858, guard = 25858, constant_flags = 25858, extra = 25858}}
#6  xdebug_throw_exception_hook (exception=0x719eb6bfedc0) at /tmp/pear/temp/xdebug/src/base/base.c:1516
        code = <optimized out>
        message = <optimized out>
        file = <optimized out>
        line = <optimized out>
        exception_ce = <optimized out>
        code_str = <optimized out>
        dummy = <optimized out>
Additional Information

PHP 8.3.21 (cli) (built: May 19 2025 14:17:50) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.21, Copyright (c) Zend Technologies
with Zend OPcache v8.3.21, Copyright (c), by Zend Technologies
with Xdebug v3.4.3, Copyright (c) 2002-2025, by Derick Rethans

TagsNo tags attached.
Operating SystemUbuntu + Docker Alpine
PHP Version8.3.10-8.3.19

Activities

derick

2025-05-20 18:19

administrator   ~0007289

Can you please provide steps on how I can reproduce this? I have seen this reported a few times not, but never with an example that shows the issue — not even with a generally too large example.

f.bosch@genkgo.nl

2025-05-20 19:48

reporter   ~0007290

Derick, I wish I could do that, but once I extract the bits of code, it doesn't crash anymore. I can share my minimal example that does not crash though.

<?php
class Placeholders {
/**

  • @var \Closure(): (self)|null
    */
    private ?\Closure $value = null;

    public function __construct(private array $collection = [], private array $scopedCollection = [])
    {
    }
    public function withCallbackScope(string $scope, \Closure $callback): Placeholders
    {
    $clone = clone $this;
    $clone->scopedCollection[$scope] = new self();
    $clone->scopedCollection[$scope]->value = $callback;
    return $clone;
    }

    public function getScope(string $scope): Placeholders
    {
    if (!isset($this->scopedCollection[$scope])) {
    throw new \InvalidArgumentException('Cannot find key ' . $scope);
    }

    return $this->scopedCollection[$scope];

    }

    public function get(string $key): string
    {
    if ($this->value !== null) {
    $value = \call_user_func($this->value);
    $this->collection = $value->collection;
    $this->value = null;
    }

    if (!isset($this->collection[$key])) {

    // return ''; // <- solves the crash
    throw new \InvalidArgumentException('Cannot find key ' . $key); // <- here is the crash
    }

    return $this->collection[$key];

    }
    }

$placeholders = (new Placeholders())
->withCallbackScope('x', fn () => new Placeholders([
'letterhead' => 'letterhead',
'street' => 'street',
'postalcode' => 'postalcode',
'city' => 'city',
]));

class Resolver {
public function resolve(Placeholders $placeholders)
{
$result = '';
try {
$result .= $placeholders->getScope('x')->get('letterhead');
$result .= $placeholders->getScope('x')->get('street');
$result .= $placeholders->getScope('x')->get('postalcode');
$result .= $placeholders->getScope('x')->get('city');
$result .= $placeholders->getScope('x')->get('country');
} catch (\InvalidArgumentException) {
}

    return $result;
}

}

$resolver = new Resolver();
echo $resolver->resolve($placeholders);

echo "end";

f.bosch@genkgo.nl

2025-05-20 19:53

reporter   ~0007291

Now as attachment. But again, it does not crash. I was not able to create a reproducible crashing example.

test.php (2,124 bytes)   
<?php
class Placeholders {
    /**
     * @var \Closure(): (self)|null
     */
    private ?\Closure $value = null;

    public function __construct(private array $collection = [], private array $scopedCollection = [])
    {
    }
    public function withCallbackScope(string $scope, \Closure $callback): Placeholders
    {
        $clone = clone $this;
        $clone->scopedCollection[$scope] = new self();
        $clone->scopedCollection[$scope]->value = $callback;
        return $clone;
    }

    public function getScope(string $scope): Placeholders
    {
        if (!isset($this->scopedCollection[$scope])) {
            throw new \InvalidArgumentException('Cannot find key ' . $scope);
        }

        return $this->scopedCollection[$scope];
    }

    public function get(string $key): string
    {
        if ($this->value !== null) {
            $value = \call_user_func($this->value);
            $this->collection = $value->collection;
            $this->value = null;
        }

        if (!isset($this->collection[$key])) {
//            return '';  // <- solves the crash
            throw new \InvalidArgumentException('Cannot find key ' . $key); // <- here is the crash
        }

        return $this->collection[$key];
    }
}

$placeholders = (new Placeholders())
    ->withCallbackScope('x', fn () => new Placeholders([
        'letterhead' => 'letterhead',
        'street' => 'street',
        'postalcode' => 'postalcode',
        'city' => 'city',
    ]));

class Resolver {
    public function resolve(Placeholders $placeholders)
    {
        $result = '';
        try {
            $result .= $placeholders->getScope('x')->get('letterhead');
            $result .= $placeholders->getScope('x')->get('street');
            $result .= $placeholders->getScope('x')->get('postalcode');
            $result .= $placeholders->getScope('x')->get('city');
            $result .= $placeholders->getScope('x')->get('country');
        } catch (\InvalidArgumentException) {
        }

        return $result;
    }
}

$resolver = new Resolver();
echo $resolver->resolve($placeholders);

echo "end";
test.php (2,124 bytes)   

SR

2025-05-22 13:07

reporter   ~0007292

I confirm the crash.
Latest php 8.3 and xdebug-3.4.3 (works with 3.4.2)

Issue History

Date Modified Username Field Change
2025-05-20 07:47 f.bosch@genkgo.nl New Issue
2025-05-20 18:19 derick Assigned To => derick
2025-05-20 18:19 derick Status new => feedback
2025-05-20 18:19 derick Note Added: 0007289
2025-05-20 19:48 f.bosch@genkgo.nl Note Added: 0007290
2025-05-20 19:48 f.bosch@genkgo.nl Status feedback => assigned
2025-05-20 19:53 f.bosch@genkgo.nl Note Added: 0007291
2025-05-20 19:53 f.bosch@genkgo.nl File Added: test.php
2025-05-22 13:07 SR Note Added: 0007292