This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 230764

Summary: PHP debugger changes strings greater than 1024 to null
Product: php Reporter: doliver3
Component: DebuggerAssignee: Ondrej Brejla <obrejla>
Status: CLOSED WONTFIX    
Severity: normal    
Priority: P3    
Version: 7.3   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 230850    
Bug Blocks:    

Description doliver3 2013-06-05 08:09:24 UTC
Putting any String into the debugger that is greater than 1024 characters (whether variable or literal string) returns null.  Concatenating 2 string values that have a resulting length greater than 1024 returns null.  

To demonstrate the basic problem get into debug on a line of PHP with xdebug then add these 2 watches:

str_repeat('a',1024) // this works
str_repeat('a',1025) // this returns the value null (null shows up as the value)

That is for demonstration, but the this is really a huge problem because Netbeans actually changes the values of the variables you are watching and concatenating as well.  Also if one variable is changed to null by Netbeans then concatenating that value with another valid String will return a null. 

Issues:
1. The debugger should not be altering the underlying values arbitrarily. 

If Netbeans is just trying to protect itself from too much memory usage, the appropriate IDE behavior should be truncation with a note to let the developer know that it is trunctated. This would be tremendously better than changing the string from a value to a null - changing the value is completely awful behavior because as a developer one doesn't know the source of this arbitrary null value. 

It took me hours to realize that it was actually Netbeans causing this awful behavior rather than any code or library or even xdebug.  Developers should be able to trust their IDE not to lie to them about values and IDEs should not alter executing code values arbitrarily without notification. 

2. Netbeans should offer a setting value to allow this arbitrary 1024 value to be increased to whatever the developer needs the setting to be.
Comment 1 Jiri Kovalsky 2013-06-05 08:14:06 UTC
This is not a problem of Java Debugger.
Comment 2 doliver3 2013-06-05 09:41:02 UTC
Good to know that it is not a problem with Java debugger if you've tested that.  Thanks. 

However, it is still a huge issue with the PHP debugger, and as far as I can tell it is not related to xdebug settings.  

In xdebug, I can bump up the size of variables it is handling by setting the value of xdebug.var_display_max_data to -1 or to some specific byte size like 2048.  However, Netbeans still ignores these settings and always sets any Strings larger than 1024 to be the value 'null'.  

The whole point of an IDE debugger is to allow the developer to see the values in the variables.  If the IDE cannot do that, the IDE's debugger is not much use.  1024 bytes is very arbitrarily low.  We often have JSON variables these days that may have many kilobytes of data in them. A PHP developer needs to be able to pull these values out using the IDE debugger.

My current xdebug settings are as follows...

[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.4.10/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
;xdebug.remote_autostart=1
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_cookie_expire_time = 36000
xdebug.var_display_max_data=2048
Comment 3 Ondrej Brejla 2013-06-05 09:51:27 UTC
I just tested that on Mac with the latest dev build and I see a bit different issue. 

<?php
$test = str_repeat('a',2048);
exit; // breakpoint here
?>

If NB stops on BP, I see "Evaluating..." text in variable view. Which is strange, because if I move cursor over "$test" var, its content is shown properly and suddenly "Evaluating..." text disappears and the proper content is shown. I didn't see any "null" issue.

But I will evaluate it further. Thanks.
Comment 4 Ondrej Brejla 2013-06-05 11:10:51 UTC
I just made some evaluation...if I increase MAX_DATA directly in NB code, everything works...but if I try to set it via xdebug.var_display_max_data=2048, it's ignored. Understand...NB module doesn't get setted value, but just 2014. It seems that that directive is ignored in php.ini.

I will try to make some more evaluation...
Comment 5 Ondrej Brejla 2013-06-05 11:20:12 UTC
I have a suspicion that we both edit wrong php.ini :)
Comment 6 Ondrej Brejla 2013-06-05 11:29:24 UTC
No we edit the right PHP.ini ;) When I set a logging directory, communication is logged properly.

But...In log I see this line: 

<- feature_get -i 69 -n max_data
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_get" transaction_id="69" feature_name="max_data" supported="1"><![CDATA[1024]]></response>

Which is strange, because I have:

xdebug.var_display_max_data = 3000

So for me it seems that XDebug has an issue itself...that it still sends us wrong max_data value, even when we set it directly in php.ini...
Comment 7 Ondrej Brejla 2013-06-05 11:34:03 UTC
(In reply to comment #6)
> No we edit the right PHP.ini ;) 

Ehm...probably not exactly :) Logging works when I try to debug my script by "Run Configuration -> Script" if I change run configuration to  "Local Web Site", logging doesn't work.

But it still doesn't solve a problem, why xdebug.var_display_max_data = 3000 directive is ignored by XDebug even though the logging directive works...
Comment 8 Ondrej Brejla 2013-06-06 09:45:42 UTC
I just tested that on linux and it seems that the xdebug.var_display_max_data directive is ignored there too :( Everytime I get 1024. It doesn't metter what I set in php.ini, first returned value from XDebug itself is 1024.
Comment 9 Ondrej Brejla 2013-06-06 11:30:14 UTC
I found the cause of such a strange behavior...xdebug issue: http://bugs.xdebug.org/view.php?id=327

So it's a common behavior (since IDEs use remote debugging...).

Ok, so I'll add an input to Options -> PHP -> Debugging to set a custom value of Max Data.
Comment 10 Ondrej Brejla 2013-06-06 12:20:44 UTC
Debugger part is done in web-main #ca5fe3f4c6ed. Waiting for issue #230850 to complete it.
Comment 11 Ondrej Brejla 2013-06-07 08:14:11 UTC
Fixed in web-main #1926847fc601
Comment 12 Quality Engineering 2013-06-08 01:11:05 UTC
Integrated into 'main-golden', will be available in build *201306072301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/1926847fc601
User: Ondrej Brejla <obrejla@netbeans.org>
Log: #230764 - PHP debugger changes strings greater than 1024 to null
Comment 13 Panda77 2019-01-31 15:49:56 UTC
same problem with netbeans 8.1

Putting any String into the debugger that is greater than 1024 characters returns null.

i have set xdebug.var_display_max_data=3000...

but nothing
Comment 14 Jiri Kovalsky 2019-01-31 18:19:18 UTC
Nobody is going to fix defects in NetBeans 8.1. If you can reproduce the issue in Apache NetBeans 10.0 then please report this defect to Apache Jira here: https://issues.apache.org/jira/secure/CreateIssue!default.jspa Thank you.
Comment 15 Jiri Kovalsky 2019-01-31 18:20:15 UTC
Closing.