View Issue Details

IDProjectCategoryView StatusLast Update
0001993XdebugStep Debuggingpublic2021-11-20 19:50
ReporterZobo Assigned Toderick  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version3.0.4 
Fixed in Version3.1.0 
Summary0001993: eval-ing broken code causes stepping to break
Description

vscode-php-debug uses eval to display watched variables.

People can write anything in there so we get strange thins. If we eval broken code, the PHP VM stops playing along.

The example we have here is: this.$

Steps To Reproduce

CODE START
<?php

echo "1";
echo "2";
echo "3";
CODE END

dbgpclient without eval:

Connect from [::1]:62950
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php" language="PHP" xdebug:language_version="8.0.4RC1" protocol_version="1.0" appid="10100"><engine version="3.0.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2021 by Derick Rethans]]></copyright></init>
DBGp/1.0: Xdebug 3.0.4 — For PHP 8.0.4RC1
Debugging file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php (ID: 10100/)
(cmd) step_into
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="1" status="break" reason="ok"><xdebug:message filename="file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php" lineno="3"></xdebug:message></response>
1 | step_into > break/ok
1 | file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php:3

(cmd)
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="2" status="break" reason="ok"><xdebug:message filename="file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php" lineno="4"></xdebug:message></response>
2 | step_into > break/ok
2 | file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php:4

(cmd)
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="3" status="break" reason="ok"><xdebug:message filename="file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php" lineno="5"></xdebug:message></response>
3 | step_into > break/ok
3 | file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php:5

(cmd)
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>
4 | step_into > stopping/ok

sbgpClient with eval

Connect from [::1]:62954
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php" language="PHP" xdebug:language_version="8.0.4RC1" protocol_version="1.0" appid="27696"><engine version="3.0.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2021 by Derick Rethans]]></copyright></init>
DBGp/1.0: Xdebug 3.0.4 — For PHP 8.0.4RC1
Debugging file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php (ID: 27696/)
(cmd) step_into
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="1" status="break" reason="ok"><xdebug:message filename="file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php" lineno="3"></xdebug:message></response>
1 | step_into > break/ok
1 | file:///C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/watch2.php:3

(cmd) eval -- Ghpcy4k
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="2" status="break" reason="ok"><error code="206"><message><![CDATA[error evaluating code]]></message></error></response>
2 | eval > break/ok
2 | Error(206): error evaluating code

(cmd) step_into
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="3" status="stopping" reason="ok"></response>
3 | step_into > stopping/ok

Additional Information

This is a very linear example. If for example we call eval within a function call more strange things happen, like stepping out of function and then stopping.
If we add a xdebug_break() into the mix even wierder things, like step return reports correct line number but stack get report lineno 0...

Tagseval
Operating System
PHP Version8.0.0-8.0.4

Activities

derick

2021-07-16 15:36

administrator   ~0005929

This was a tricky one to find!

https://github.com/xdebug/xdebug/pull/759

Zobo

2021-11-20 19:50

reporter   ~0006159

Any reason this is only implemented for PHP 8? The zend_clear_exception() is defined at least down to PHP 7.2. I think that because of this we have failing cases like this one, even with Xdebug 3.1.1 https://github.com/xdebug/vscode-php-debug/issues/692
The cause here is evaling "namespace".

Issue History

Date Modified Username Field Change
2021-07-11 18:50 Zobo New Issue
2021-07-11 18:50 Zobo Tag Attached: eval
2021-07-16 15:36 derick Assigned To => derick
2021-07-16 15:36 derick Status new => closed
2021-07-16 15:36 derick Resolution open => fixed
2021-07-16 15:36 derick Fixed in Version => 3.1dev
2021-07-16 15:36 derick Note Added: 0005929
2021-09-05 16:15 derick Fixed in Version 3.1dev => 3.1.0beta1
2021-10-04 09:32 derick Fixed in Version 3.1.0beta1 => 3.1.0
2021-11-20 19:50 Zobo Note Added: 0006159