Skip to content

Commit 486bf41

Browse files
committed
Merged pull request xdebug#1022
2 parents f693f7d + aaab234 commit 486bf41

File tree

4 files changed

+121
-1
lines changed

4 files changed

+121
-1
lines changed

src/develop/stack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static void zval_from_stack_add_frame(zval *output, function_stack_entry *fse, z
463463

464464
zval_from_stack_add_frame_parameters(frame, fse, params_as_values);
465465

466-
if (add_local_vars && fse->op_array && fse->op_array->vars && !(fse->function.type & XFUNC_INCLUDES)) {
466+
if (add_local_vars && fse->op_array && fse->op_array->type == ZEND_USER_FUNCTION && fse->op_array->vars && !(fse->function.type & XFUNC_INCLUDES)) {
467467
zval_from_stack_add_frame_variables(frame, edata, fse->symbol_table, fse->op_array);
468468
}
469469

tests/develop/bug02352-php80.phpt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Test for bug #2352: Crash with storing exception traces and __invoke (< PHP 8.1)
3+
--SKIPIF--
4+
<?php
5+
require __DIR__ . '/../utils.inc';
6+
check_reqs('PHP < 8.1');
7+
?>
8+
--INI--
9+
xdebug.mode=develop
10+
--FILE--
11+
<?php
12+
class RedisProxy {
13+
function __construct(public Closure $c)
14+
{
15+
}
16+
17+
function __call($method, $args)
18+
{
19+
$this->c->__invoke($args);
20+
}
21+
}
22+
23+
$c = function(array $args)
24+
{
25+
throw new Exception();
26+
};
27+
28+
$rp = new RedisProxy($c);
29+
$rp->isConnected();
30+
?>
31+
--EXPECTF--
32+
Fatal error: Uncaught Exception in %sbug02352-php80.php on line 15
33+
34+
Exception: in %sbug02352-php80.php on line 15
35+
36+
Call Stack:
37+
%w%f %w%d 1. {main}() %sbug02352-php80.php:0
38+
%w%f %w%d 2. RedisProxy->isConnected() %sbug02352-php80.php:19
39+
%w%f %w%d 3. RedisProxy->__call($method = 'isConnected', $args = []) %sbug02352-php80.php:19
40+
%w%f %w%d 4. Closure->__invoke(%s = []) %sbug02352-php80.php:9
41+
%w%f %w%d 5. {closure:%sbug02352-php80.php:13-16}($args = []) %sbug02352-php80.php:9

tests/develop/bug02352-php81.phpt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Test for bug #2352: Crash with storing exception traces and __invoke (= PHP 8.1)
3+
--SKIPIF--
4+
<?php
5+
require __DIR__ . '/../utils.inc';
6+
check_reqs('PHP >= 8.1, < 8.2');
7+
?>
8+
--INI--
9+
xdebug.mode=develop
10+
--FILE--
11+
<?php
12+
class RedisProxy {
13+
function __construct(public Closure $c)
14+
{
15+
}
16+
17+
function __call($method, $args)
18+
{
19+
$this->c->__invoke($args);
20+
}
21+
}
22+
23+
$c = function(array $args)
24+
{
25+
throw new Exception();
26+
};
27+
28+
$rp = new RedisProxy($c);
29+
$rp->isConnected();
30+
?>
31+
--EXPECTF--
32+
Fatal error: Uncaught Exception in %sbug02352-php81.php on line 15
33+
34+
Exception: in %sbug02352-php81.php on line 15
35+
36+
Call Stack:
37+
%w%f %w%d 1. {main}() %sbug02352-php81.php:0
38+
%w%f %w%d 2. RedisProxy->__call($method = 'isConnected', $args = []) %sbug02352-php81.php:19
39+
%w%f %w%d 3. Closure->__invoke(%s = []) %sbug02352-php81.php:9
40+
%w%f %w%d 4. {closure:%sbug02352-php81.php:13-16}($args = []) %sbug02352-php81.php:9

tests/develop/bug02352-php82.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
Test for bug #2352: Crash with storing exception traces and __invoke (>= PHP 8.2)
3+
--SKIPIF--
4+
<?php
5+
require __DIR__ . '/../utils.inc';
6+
check_reqs('PHP >= 8.2');
7+
?>
8+
--INI--
9+
xdebug.mode=develop
10+
--FILE--
11+
<?php
12+
class RedisProxy {
13+
function __construct(public Closure $c)
14+
{
15+
}
16+
17+
function __call($method, $args)
18+
{
19+
$this->c->__invoke($args);
20+
}
21+
}
22+
23+
$c = function(array $args)
24+
{
25+
throw new Exception();
26+
};
27+
28+
$rp = new RedisProxy($c);
29+
$rp->isConnected();
30+
?>
31+
--EXPECTF--
32+
Fatal error: Uncaught Exception in %sbug02352-php82.php on line 15
33+
34+
Exception: in %sbug02352-php82.php on line 15
35+
36+
Call Stack:
37+
%w%f %w%d 1. {main}() %sbug02352-php82.php:0
38+
%w%f %w%d 2. RedisProxy->__call($method = 'isConnected', $args = []) %sbug02352-php82.php:19
39+
%w%f %w%d 3. {closure:%sbug02352-php82.php:13-16}($args = []) %sbug02352-php82.php:9

0 commit comments

Comments
 (0)