Skip to content

Commit 10a06ff

Browse files
committed
Fixed issue #2386: Crashes when running context_get in an exception thrown from an internal function
1 parent a1af24f commit 10a06ff

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

src/debugger/handler_dbgp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,7 @@ static int attach_context_vars(xdebug_xml_node *node, xdebug_var_export_options
21322132
}
21332133

21342134
if (
2135+
ZEND_USER_CODE(EG(current_execute_data)->func->type) &&
21352136
EG(current_execute_data)->opline->opcode == ZEND_EXT_STMT &&
21362137
(
21372138
EG(current_execute_data)->opline->op1_type == IS_VAR || EG(current_execute_data)->opline->op1_type == IS_TMP_VAR

tests/debugger/bug02386.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
date('Y-m-d', new DateTimeImmutable('now'));

tests/debugger/bug02386.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 #2386: Crashes when running context_get in an exception thrown from an internal function
3+
--SKIPIF--
4+
<?php
5+
require __DIR__ . '/../utils.inc';
6+
check_reqs('dbgp');
7+
?>
8+
--FILE--
9+
<?php
10+
require 'dbgp/dbgpclient.php';
11+
$filename = dirname(__FILE__) . '/bug02386.inc';
12+
13+
$commands = array(
14+
"breakpoint_set -t exception -x *",
15+
'run',
16+
"context_get",
17+
'detach',
18+
);
19+
20+
dbgpRunFile( $filename, $commands );
21+
?>
22+
--EXPECTF--
23+
<?xml version="1.0" encoding="iso-8859-1"?>
24+
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file://bug02386.inc" language="PHP" xdebug:language_version="" protocol_version="1.0" appid=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2099 by Derick Rethans]]></copyright></init>
25+
26+
-> breakpoint_set -i 1 -t exception -x *
27+
<?xml version="1.0" encoding="iso-8859-1"?>
28+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="1" id="{{PID}}0001"></response>
29+
30+
-> run -i 2
31+
<?xml version="1.0" encoding="iso-8859-1"?>
32+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="2" status="break" reason="ok"><xdebug:message filename="file://bug02386.inc" lineno="2" exception="TypeError"><![CDATA[date(): Argument #2 ($timestamp) must be of type ?int, DateTimeImmutable given]]></xdebug:message></response>
33+
34+
-> context_get -i 3
35+
<?xml version="1.0" encoding="iso-8859-1"?>
36+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="3" context="0"></response>
37+
38+
-> detach -i 4
39+
<?xml version="1.0" encoding="iso-8859-1"?>
40+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="detach" transaction_id="4" status="stopping" reason="ok"></response>

0 commit comments

Comments
 (0)