View Issue Details

IDProjectCategoryView StatusLast Update
0000292XdebugUncategorizedpublic2007-07-14 14:54
Reportermathieuk Assigned Toderick  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionno change required 
Summary0000292: xdebug doesn't provide a stacktrace after an uncaught exception
Description

<?php

function test()
{
throw new exception();
}

test();

?>

Consider the following code and a debugging session that has an exception breakpoint set on "Fatal error":
<?php

function test()
{
throw new exception();
}

test();

?>

Expected behaviour:

An uncaught exception triggers a fatal error, which is caught as a breakpoint by Xdebug. Xdebug transfers control over to the client. When the client asks for a stacktrace using the DBGp command 'stack_get', the user gets back a proper DBGp response, containing a stacktrace containing entries for the function 'test' and the function '{main}'.

Actual behaviour in 2.0RC4

The uncaught exception indeed triggers a fatal error which is properly caught by Xdebug. When requesting the stacktrace (without a depth specificier) you get an empty response:

(cmd) stack_get -i waa3
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug&quot; command="stackget" transaction
id="waa3"></response>

Full debugclient conversation:

Waiting for debug server to connect.
Connect
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug&quot; fileuri="file:///C%3A%5CProgram%20Fi
les%5Cxampp%5Cxampp%5Chtdocs%5Cxdebug%5Cexception.php" language="PHP" protocol_version="1.0" appid="424" idekey="0"><eng
ine version="2.0.0RC4-dev"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xd
ebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2007 by Derick Rethans]]></copyright></init>

(cmd) breakpoint_set -i waa0 -t exception -x "Fatal error"
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug&quot; command="breakpoint_set" transac
tion_id="waa0" id="4240002"></response>

(cmd) run -i waa
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug&quot; command="run" transaction_id="wa
a" status="break" reason="ok"><xdebug:message filename="C:\Program Files\xampp\xampp\htdocs\xdebug\exception.php" lineno
="5" exception="Fatal error"><![CDATA[Uncaught exception 'Exception' in C:\Program Files\xampp\xampp\htdocs\xdebug\excep
tion.php:5
Stack trace:
#0 C:\Program Files\xampp\xampp\htdocs\xdebug\exception.php(8): test()
#1 {main}
thrown]]></xdebug:message></response>

(cmd) stack_get -i waa3
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug&quot; command="stackget" transaction
id="waa3"></response>

(cmd) stack_get -i waa4 -d 0
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug&quot; command="stackget" transaction
id="waa4"><error code="1"><message><![CDATA[parse error in command]]></message></error></response>

(cmd) stack_get -i waa5 -d 1
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug&quot; command="stackget" transaction
id="waa4" status="break" reason="ok"><error code="301"><message><![CDATA[stack depth invalid]]></message></error></respo
nse>

TagsNo tags attached.
Operating System
PHP Version5.2.1

Activities

derick

2007-07-14 14:54

administrator   ~0000692

This is not a bug. The uncaught fatal error happens after PHP wind down all the stack to find a matching catch block. If it can't find one it's basically back to stack level -1, which is even before the script starts. There is nothing that Xdebug can do about this.

It works for just showing the uncaught exception stack trace because Xdebug keeps internally a full stack in a formatted message for every exception.

Issue History

Date Modified Username Field Change
2007-07-12 07:13 mathieuk New Issue
2007-07-14 14:54 derick Status new => resolved
2007-07-14 14:54 derick Resolution open => no change required
2007-07-14 14:54 derick Assigned To => derick
2007-07-14 14:54 derick Note Added: 0000692
2016-07-31 12:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 12:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized