View Issue Details

IDProjectCategoryView StatusLast Update
0001586XdebugUncategorizedpublic2019-11-12 13:56
ReporterLanaZem Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.6.0 
Fixed in Version2.7.2 
Summary0001586: error_reporting()'s return value is incorrect during debugger's 'eval' command
Description

Xdebug sends error notification even if they are disabled in php.ini

Steps To Reproduce

1) Set error_reporting to E_ALL & ~E_NOTICE
2) Create a php script:


<?php

echo $undefined;


3) Make sure that regular execution doesn't generate PHP Notification
4) Start Xdebug debug session
5) Enable notify feature

<- feature_set -i 5 -n notify_ok -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="5" feature="notify_ok" success="1"></response>

6) Finish debug session
7) Note that there's a notification in xdebug log:

-> <notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" name="error"><xdebug:message filename="file:///path/to/project/withNotice.php" lineno="6" type="Notice"><![CDATA[Undefined variable: x]]></xdebug:message></notify>

Additional Information

PhpStorm issue: https://youtrack.jetbrains.com/issue/WI-43921

TagsNo tags attached.
Attached Files
xdebug_with_notify.log (13,202 bytes)   
Log opened at 2018-11-12 12:08:17
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (29).
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///home/user/PhpstormProjects/debugger/debug_console/debug/withNotice.php" language="PHP" xdebug:language_version="7.1.1" protocol_version="1.0" appid="12314" idekey="PHPSTORM"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>

<- feature_set -i 1 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>

<- feature_set -i 2 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>

<- feature_set -i 3 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="max_children" success="1"></response>

<- feature_set -i 4 -n extended_properties -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="4" feature="extended_properties" success="1"></response>

<- feature_set -i 5 -n notify_ok -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="5" feature="notify_ok" success="1"></response>

<- stdout -i 6 -c 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stdout" transaction_id="6" success="1"></response>

<- status -i 7
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="7" status="starting" reason="ok"></response>

<- step_into -i 8
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="8" status="break" reason="ok"><xdebug:message filename="file:///home/user/PhpstormProjects/debugger/debug_console/debug/withNotice.php" lineno="3"></xdebug:message></response>

<- eval -i 9 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="9"><property type="bool"><![CDATA[0]]></property></response>

<- eval -i 10 -- aXNzZXQoJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="10"><property type="bool"><![CDATA[1]]></property></response>

<- eval -i 11 -- KHN0cmluZykoJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="11"><property type="string" size="9" encoding="base64"><![CDATA[MTI3LjAuMC4x]]></property></response>

<- eval -i 12 -- KHN0cmluZykoJF9TRVJWRVJbJ1NFUlZFUl9QT1JUJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="12"><property type="string" size="4" encoding="base64"><![CDATA[ODA4MQ==]]></property></response>

<- eval -i 13 -- KHN0cmluZykoJF9TRVJWRVJbJ1JFUVVFU1RfVVJJJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="13"><property type="string" size="21" encoding="base64"><![CDATA[L2RlYnVnL3dpdGhOb3RpY2UucGhw]]></property></response>

<- breakpoint_set -i 14 -t line -f file:///home/user/PhpstormProjects/debugger/debug_console/hello.php -n 7
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="14" id="123140001"></response>

<- breakpoint_set -i 15 -t line -f file:///home/user/PhpstormProjects/debugger/debug_console/hello.php -n 44
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="15" id="123140002"></response>

<- breakpoint_set -i 16 -t line -f file:///home/user/PhpstormProjects/debugger/debug_console/debug/withNotice.php -n 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="16" id="123140003"></response>

<- stack_get -i 17
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="17"><stack where="{main}" level="0" type="file" filename="file:///home/user/PhpstormProjects/debugger/debug_console/debug/withNotice.php" lineno="3"></stack></response>

<- stack_get -i 18
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="18"><stack where="{main}" level="0" type="file" filename="file:///home/user/PhpstormProjects/debugger/debug_console/debug/withNotice.php" lineno="3"></stack></response>

<- context_names -i 19
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="19"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response>

<- context_get -i 20 -d 0 -c 0
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="20" context="0"><property name="$err_level" fullname="$err_level" type="uninitialized"></property><property name="$x" fullname="$x" type="uninitialized"></property></response>

<- context_get -i 21 -d 0 -c 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="21" context="1"><property name="$_COOKIE" fullname="$_COOKIE" type="array" children="1" numchildren="6" page="0" pagesize="100"><property name="debug_session_id" fullname="$_COOKIE[&quot;debug_session_id&quot;]" type="string" size="8" encoding="base64"><![CDATA[ODM3MTk5MDA=]]></property><property name="debug_start_session" fullname="$_COOKIE[&quot;debug_start_session&quot;]" type="string" size="1" encoding="base64"><![CDATA[MQ==]]></property><property name="ZDEDebuggerPresent" fullname="$_COOKIE[&quot;ZDEDebuggerPresent&quot;]" type="string" size="14" encoding="base64"><![CDATA[cGhwLHBodG1sLHBocDM=]]></property><property name="ZendDebuggerCookie" fullname="$_COOKIE[&quot;ZendDebuggerCookie&quot;]" type="string" size="40" encoding="base64"><![CDATA[MTI3LjAuMC4xOjEwMTM3OjB8fDA0Q3w3Nzc0MkQ2NXw4MzcxOTkwMA==]]></property><property name="prof_profiler_enabled" fullname="$_COOKIE[&quot;prof_profiler_enabled&quot;]" type="string" size="1" encoding="base64"><![CDATA[MQ==]]></property><property name="XDEBUG_SESSION" fullname="$_COOKIE[&quot;XDEBUG_SESSION&quot;]" type="string" size="8" encoding="base64"><![CDATA[UEhQU1RPUk0=]]></property></property><property name="$_ENV" fullname="$_ENV" type="array" children="0" numchildren="0" page="0" pagesize="100"></property><property name="$_FILES" fullname="$_FILES" type="array" children="0" numchildren="0" page="0" pagesize="100"></property><property name="$_GET" fullname="$_GET" type="array" children="0" numchildren="0" page="0" pagesize="100"></property><property name="$_POST" fullname="$_POST" type="array" children="0" numchildren="0" page="0" pagesize="100"></property><property name="$_REQUEST" fullname="$_REQUEST" type="array" children="0" numchildren="0" page="0" pagesize="100"></property><property name="$_SERVER" fullname="$_SERVER" type="array" children="1" numchildren="23" page="0" pagesize="100"><property name="DOCUMENT_ROOT" fullname="$_SERVER[&quot;DOCUMENT_ROOT&quot;]" type="string" size="50" encoding="base64"><![CDATA[L2hvbWUvdXNlci9QaHBzdG9ybVByb2plY3RzL2RlYnVnZ2VyL2RlYnVnX2NvbnNvbGU=]]></property><property name="REMOTE_ADDR" fullname="$_SERVER[&quot;REMOTE_ADDR&quot;]" type="string" size="9" encoding="base64"><![CDATA[MTI3LjAuMC4x]]></property><property name="REMOTE_PORT" fullname="$_SERVER[&quot;REMOTE_PORT&quot;]" type="string" size="5" encoding="base64"><![CDATA[NTQ2Njg=]]></property><property name="SERVER_SOFTWARE" fullname="$_SERVER[&quot;SERVER_SOFTWARE&quot;]" type="string" size="28" encoding="base64"><![CDATA[UEhQIDcuMS4xIERldmVsb3BtZW50IFNlcnZlcg==]]></property><property name="SERVER_PROTOCOL" fullname="$_SERVER[&quot;SERVER_PROTOCOL&quot;]" type="string" size="8" encoding="base64"><![CDATA[SFRUUC8xLjE=]]></property><property name="SERVER_NAME" fullname="$_SERVER[&quot;SERVER_NAME&quot;]" type="string" size="9" encoding="base64"><![CDATA[MTI3LjAuMC4x]]></property><property name="SERVER_PORT" fullname="$_SERVER[&quot;SERVER_PORT&quot;]" type="string" size="4" encoding="base64"><![CDATA[ODA4MQ==]]></property><property name="REQUEST_URI" fullname="$_SERVER[&quot;REQUEST_URI&quot;]" type="string" size="21" encoding="base64"><![CDATA[L2RlYnVnL3dpdGhOb3RpY2UucGhw]]></property><property name="REQUEST_METHOD" fullname="$_SERVER[&quot;REQUEST_METHOD&quot;]" type="string" size="3" encoding="base64"><![CDATA[R0VU]]></property><property name="SCRIPT_NAME" fullname="$_SERVER[&quot;SCRIPT_NAME&quot;]" type="string" size="21" encoding="base64"><![CDATA[L2RlYnVnL3dpdGhOb3RpY2UucGhw]]></property><property name="SCRIPT_FILENAME" fullname="$_SERVER[&quot;SCRIPT_FILENAME&quot;]" type="string" size="71" encoding="base64"><![CDATA[L2hvbWUvdXNlci9QaHBzdG9ybVByb2plY3RzL2RlYnVnZ2VyL2RlYnVnX2NvbnNvbGUvZGVidWcvd2l0aE5vdGljZS5waHA=]]></property><property name="PHP_SELF" fullname="$_SERVER[&quot;PHP_SELF&quot;]" type="string" size="21" encoding="base64"><![CDATA[L2RlYnVnL3dpdGhOb3RpY2UucGhw]]></property><property name="HTTP_HOST" fullname="$_SERVER[&quot;HTTP_HOST&quot;]" type="string" size="14" encoding="base64"><![CDATA[MTI3LjAuMC4xOjgwODE=]]></property><property name="HTTP_CONNECTION" fullname="$_SERVER[&quot;HTTP_CONNECTION&quot;]" type="string" size="10" encoding="base64"><![CDATA[a2VlcC1hbGl2ZQ==]]></property><property name="HTTP_CACHE_CONTROL" fullname="$_SERVER[&quot;HTTP_CACHE_CONTROL&quot;]" type="string" size="9" encoding="base64"><![CDATA[bWF4LWFnZT0w]]></property><property name="HTTP_UPGRADE_INSECURE_REQUESTS" fullname="$_SERVER[&quot;HTTP_UPGRADE_INSECURE_REQUESTS&quot;]" type="string" size="1" encoding="base64"><![CDATA[MQ==]]></property><property name="HTTP_USER_AGENT" fullname="$_SERVER[&quot;HTTP_USER_AGENT&quot;]" type="string" size="105" encoding="base64"><![CDATA[TW96aWxsYS81LjAgKFgxMTsgTGludXggeDg2XzY0KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvNjkuMC4zNDk3LjEwMCBTYWZhcmkvNTM3LjM2]]></property><property name="HTTP_ACCEPT" fullname="$_SERVER[&quot;HTTP_ACCEPT&quot;]" type="string" size="85" encoding="base64"><![CDATA[dGV4dC9odG1sLGFwcGxpY2F0aW9uL3hodG1sK3htbCxhcHBsaWNhdGlvbi94bWw7cT0wLjksaW1hZ2Uvd2VicCxpbWFnZS9hcG5nLCovKjtxPTAuOA==]]></property><property name="HTTP_ACCEPT_ENCODING" fullname="$_SERVER[&quot;HTTP_ACCEPT_ENCODING&quot;]" type="string" size="17" encoding="base64"><![CDATA[Z3ppcCwgZGVmbGF0ZSwgYnI=]]></property><property name="HTTP_ACCEPT_LANGUAGE" fullname="$_SERVER[&quot;HTTP_ACCEPT_LANGUAGE&quot;]" type="string" size="50" encoding="base64"><![CDATA[ZW4tVVMsZW47cT0wLjksZXM7cT0wLjgsZnI7cT0wLjcscnU7cT0wLjYsZGU7cT0wLjU=]]></property><property name="HTTP_COOKIE" fullname="$_SERVER[&quot;HTTP_COOKIE&quot;]" type="string" size="198" encoding="base64"><![CDATA[ZGVidWdfc2Vzc2lvbl9pZD04MzcxOTkwMDsgZGVidWdfc3RhcnRfc2Vzc2lvbj0xOyBaREVEZWJ1Z2dlclByZXNlbnQ9cGhwLHBodG1sLHBocDM7IFplbmREZWJ1Z2dlckNvb2tpZT0xMjcuMC4wLjElM0ExMDEzNyUzQTB8fDA0Q3w3Nzc0MkQ2NXw4MzcxOTkwMDsgcHJvZl9wcm9maWxlcl9lbmFibGVkPTE7IFhERUJVR19TRVNTSU9OPVBIUFNUT1JN]]></property><property name="REQUEST_TIME_FLOAT" fullname="$_SERVER[&quot;REQUEST_TIME_FLOAT&quot;]" type="float"><![CDATA[1542024497.6028]]></property><property name="REQUEST_TIME" fullname="$_SERVER[&quot;REQUEST_TIME&quot;]" type="int"><![CDATA[1542024497]]></property></property></response>

<- context_get -i 22 -d 0 -c 2
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="22" context="2"></response>

<- run -i 23
-> <notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" name="error"><xdebug:message filename="file:///home/user/PhpstormProjects/debugger/debug_console/debug/withNotice.php" lineno="6" type="Notice"><![CDATA[Undefined variable: x]]></xdebug:message></notify>

-> <stream xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" type="stdout" encoding="base64"><![CDATA[YWxsIGRvbmUK]]></stream>

-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="23" status="stopping" reason="ok"></response>

<- run -i 24
Log closed at 2018-11-12 12:08:22

xdebug_with_notify.log (13,202 bytes)   
Operating System
PHP Version7.1.0-7.1.4

Activities

derick

2018-12-01 11:28

administrator   ~0004733

I saw the issue when you submitted it, but so far I had neglected to reply as I am unsure whether Xdebug is doing anything wrong here. I'm going to argue that it doesn't.

As Xdebug is a debugging tool, it should provide as much information as it can. When an IDE sets the -n notify_ok -v 1 it indicates that the debug engine may send the IDE notifications. These notifications are not necessarily restricted to error notifications (https://xdebug.org/docs-dbgp.php#error-notification), but can in the future also include breakpoint_resolved notifications (these are currently unimplemented in Xdebug today, but part of a future feature, as requested by the PhpStorm team).

The DBGp specification says:

When a language engine creates a debugging notification, the debugger engine MAY convert this to a DBGp notification.

The language engine (PHP) creates a debugging notice (including formatting, stack traces, etc) regardless of whether PHP outputs it to the screen. The decision to show debugging information is taken much later. This means that leaving many notices unfixed in your PHP script actually creates quite a slow down to begin with (even if Xdebug is not involved at all).

As a debugging notice is created, Xdebug decides to send it over the DBGp connection to the IDE, to point out that there is a mistake in the script. I would say that it should continue to do so.

LanaZem

2018-12-03 10:30

reporter   ~0004742

Thank you for the answer!
Ok, it make sense.

We'll think how it should be fixed on PhpStorm side. Probably we should show error according to error level but notify user if there are too much hidden notifications and warnings.

derick

2019-01-22 22:30

administrator   ~0004836

Thanks Svetlana. I'll close the issue for now. If we can come up with a better solution in the future, then we can create a new issue for it.

cheers,
Derick

LanaZem

2019-05-02 14:38

reporter   ~0005011

Last edited: 2019-05-06 06:01

My colleague is currently looking how can we fix this issue on IDE side and we can't find a good way to find error reporting level for a current debug process.
If we try to evaluate "error_reporting()" on IDE side, we always get 0.

Is there more appropriate way to get the error_reporting level during debugging ?

To reproduce:
1) Create a PHP script


<?php

function sum($a, $b) {
return $a + $b;
}

echo error_reporting() . PHP_EOL;
error_reporting(E_ALL);
echo error_reporting() . PHP_EOL;

$a = 1 + 179;
echo $a . PHP_EOL;

2) Place a breakpoint on lines 7 and 12. In both cases, evaluating 'error_reporting()' will return 0.

xdebug.log:


...
[25705] <- eval -i 34 -- JEdMT0JBTFNbJ0lERV9FVkFMX0NBQ0hFJ11bJzkwZmI4NjBkLTgwOGUtNDRmOC1hMzk2LTM0N2RiZDkwNjU3OCddPWVycm9yX3JlcG9ydGluZygpOw==
[25705] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="34"><property type="int"><![CDATA[0]]></property></response>

derick

2019-05-02 15:05

administrator   ~0005012

I'll have a look again.

derick

2019-05-06 06:01

administrator   ~0005017

I've found out why your eval statement returns 0: https://github.com/derickr/xdebug/blob/master/xdebug_handler_dbgp.c#L935 — Xdebug sets the error_reporting internally to 0 in case the eval command is used. I believe that's because I didn't/couldn't rely on eval always being used on correct PHP code, as it is user input (i.e., people can put random stuff in PhpStorm's watches, and I didn't want that then to show errors in their HTML output). Now the question is how to fix this.

derick

2019-05-06 09:37

administrator   ~0005018

This is now fixed in the xdebug_2_7 and master branches.

cljk

2019-11-12 13:21

reporter   ~0005178

Is it possible that this bug is still unfixed in 2.8?

I´m debugging with IntelliJ Ultimate 2019.2 and Xdebug 2.8.0 on Windows PHP 7.3 x64 (VC15).
The problem I´m facing is described here:
https://youtrack.jetbrains.com/issue/WI-43921

IntelliJ outputs a lot of garbace (NOTICEs) when in debugging mode - despite it should not...

derick

2019-11-12 13:56

administrator   ~0005179

@cljk Your comment is unrelated to this report. This report is about error_reporting() returning the wrong value.

The youtrack issue that you linked to explains why these extra notices are not a bug in Xdebug.

Issue History

Date Modified Username Field Change
2018-11-12 12:18 LanaZem New Issue
2018-11-12 12:18 LanaZem File Added: xdebug_with_notify.log
2018-12-01 11:28 derick Note Added: 0004733
2018-12-02 18:45 derick Assigned To => derick
2018-12-02 18:45 derick Status new => feedback
2018-12-03 10:30 LanaZem Note Added: 0004742
2018-12-03 10:30 LanaZem Status feedback => assigned
2019-01-22 22:30 derick Note Added: 0004836
2019-01-22 22:30 derick Status assigned => resolved
2019-01-22 22:30 derick Resolution open => no change required
2019-05-02 14:38 LanaZem Note Added: 0005011
2019-05-02 15:05 derick Status resolved => acknowledged
2019-05-02 15:05 derick Note Added: 0005012
2019-05-06 06:01 derick Note Added: 0005017
2019-05-06 06:01 derick Note Edited: 0005011
2019-05-06 09:28 derick Summary Error notifier doesn't respect error_reporting level => error_reporting()'s return value is incorrect during debugger's 'eval' command
2019-05-06 09:28 derick Steps to Reproduce Updated
2019-05-06 09:37 derick Status acknowledged => closed
2019-05-06 09:37 derick Fixed in Version => 2.7.0dev
2019-05-06 09:37 derick Note Added: 0005018
2019-05-06 09:38 derick Resolution no change required => fixed
2019-05-06 15:46 derick Fixed in Version 2.7.0dev => 2.7.2
2019-11-12 13:21 cljk Note Added: 0005178
2019-11-12 13:56 derick Note Added: 0005179
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized