ActiveState Community

Viewing arrays while debugging does not always work

Posted by aclight on 2008-06-25 06:48

I'm using Komodo IDE 4.4 on OSX Leopard. After installing 4.4 yesterday, I noticed that sometimes when I was debugging, and added a breakpoint to stop execution, the debug panel in the lower left of the screen would show a variable as being of type Array, but if I click the triangle on the left side to show all of the elements of the array, it did not expand properly and no elements were shown. Often, if I let execution finish and then reloaded the page, I would be able to see the elements of the array the second time around. Since the exact same code was being executed, the values of any particular array would have been the same in both cases, so this is not due to the array having no elements.

Initially I was seeing this with an older version of the xdebug binary (from late last year). So I copied the new version of the xdebug.so file that comes with Komodo into place and I've made sure that the php.ini file loads this newer version. I get the same results with this new xdebug.so. In Komodo 4.3 I did not have this problem at all.

From phpinfo(), xdebug version is 2.1.0-dev. PHP version is 5.2.5. Apache version is 2.0.59. MAMP is providing PHP and Apache.

The relevant section from my php.in is:

; xdebug config for Linux and Mac OS X
zend_extension=/Applications/MAMP/Library/share/php/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.idekey=aclight

Please let me know what further information I can provide to help determine the cause of this.
Thanks

jeffg | Wed, 2008-06-25 09:12

If possible, can you provide a simple example script we can use to reproduce the issue? Thanks. The variable handling code in Komodo's PHP debugger was changed somewhat to handle variable sorting for 4.4, and those changes may have caused this issue.

--
JeffG

aclight | Wed, 2008-06-25 09:58

That may not be very easy. I'm writing/debugging Drupal modules, so to exactly reproduce what I'm doing would require ~100 files or so. Plus, given that for any individual file I don't always get this problem in the same condition, I'm not sure that just sending you those files and pointing you to put the breakpoint in a certain position would be helpful.

But next time I get this problem, I'll try to investigate a bit more and see if I can create a relatively simple test case for you.

aclight | Wed, 2008-06-25 10:17

Also, for what it's worth, when this happens, if I click the triangle to expand the array elements (but none are shown for some reason), any time I mouse over the triangle the cursor turns into the little clock instead of the regular cursor. Maybe this indicates some processing gone awry.

If I var_dump() the value of the array, it looks like this:

array
  'api' => string '42' (length=2)
  'submit' => string 'Apply' (length=5)
  'form_build_id' => string 'form-f21178004086995c130772ef93b2168c' (length=37)
  'form_token' => string '7d46b793cded65c2690c954e38549a61' (length=32)
  'form_id' => string 'views_exposed_form' (length=18)
  '' => string 'Apply' (length=5)

So it's not a very complicated array and it doesn't look like anything funny is going on.

ToddW | Wed, 2008-06-25 15:35

I have not been able to reproduce this problem as yet. I'm using drupal as my testcase, and have not run across this particular problem... the only thing I've noticed is the collapsing and re-expanding of variables causes an exception:
http://bugs.activestate.com/show_bug.cgi?id=77890

Does the variable viewer return to normal and show the expanded array values after you perform a debugger step command?

Cheers,
Todd

aclight | Wed, 2008-06-25 17:52

Does the variable viewer return to normal and show the expanded array values after you perform a debugger step command?

Nope, that doesn't do it.

jeffg | Wed, 2008-06-25 10:27

Ah, ok; I can see it would be pretty useless to try to get a repeatable repro case for this issue. Instead, I'd like to see if Komodo isproducing any errors when this happens.

1. add this macro code to a new macro in your toolbox:

var os = Components.classes['@activestate.com/koOs;1'].getService(Components.interfaces.koIOs);
try {
    appdir = komodo.interpolate('%(path:hostUserDataDir)');
    var logFile = os.path.join(appdir,'pystderr.log');
    var winOpts = "centerscreen,chrome,resizable,scrollbars,dialog=no,close";
    window.openDialog('chrome://komodo/content/tail/tail.xul',"_blank",winOpts,logFile);
} catch(e) { alert(e); }
var os = Components.classes['@activestate.com/koOs;1'].getService(Components.interfaces.koIOs);
try {
    appdir = komodo.interpolate('%(path:hostUserDataDir)');
    var logFile = os.path.join(appdir,'pystderr.log');
    var winOpts = "centerscreen,chrome,resizable,scrollbars,dialog=no,close";
    window.openDialog('chrome://komodo/content/tail/tail.xul',"_blank",winOpts,logFile);
} catch(e) { alert(e); }

2. the next time you run into this situation, run the macro to open the Komodo watch window pointed at the error log. Are there any errors in the error log?

--
JeffG

aclight | Wed, 2008-06-25 10:35

Does this look helpful?

There are a lot of errors in that window, but this is the most recent.

ERROR: variableTreeView: 
-- EXCEPTION START --
+ message (string) 'name1 has no properties'
+ fileName (string) 'chrome://komodo/content/debugger/variableOutlinerView.js'
+ lineNumber (number) 305
+ stack (string) 1030 chars
+ name (string) 'TypeError'
*
([object Object],[object Object])@chrome://komodo/content/debugger/variableOutlinerView.js:305
sort((function (variable1, variable2) {var name1 = variable1.name || variable1.debugprop.name || variable1.fullname;var name2 = variable2.name || variable2.debugprop.name || variable2.fullname;name1 = name1.toLowerCase();name2 = name2.toLowerCase();if (name1 == "...next page...") {return 1;} else if (name2 == "...next page...") {return -1;}var m1 = name1.match(/\[(\d+)\]/);if (m1) {m2 = name2.match(/\[(\d+)\]/);if (m2) {return parseInt(m1[1]) - parseInt(m2[1]);}}if (name1 > name2) {return 1;}if (name1 < name2) {return -1;}return 0;}))@:0
([object Array])@chrome://komodo/content/debugger/variableOutlinerView.js:345
([object Array],1,1)@chrome://komodo/content/debugger/variableOutlinerView.js:376
([object Object],1)@chrome://komodo/content/debugger/variableOutlinerView.js:353
(1,[object Object])@chrome://komodo/content/debugger/variableOutlinerView.js:559
(1)@chrome://komodo/content/debugger/variableOutlinerView.js:496
@:0
-- EXCEPTION END --

jeffg | Wed, 2008-06-25 10:49

It definitely seems like that error might be related. I've logged a bug for this issue:

http://bugs.activestate.com/show_bug.cgi?id=78260

If you don't mind, can you try this for me:

- re-start Komodo ( this will blow away that error log )
- continue working as normal
- the next time you encounter the error, run that macro again to open the error log, and paste the *entire* contents of the error log into the above bug.

The reason why I want all of it is there may be some related errors earlier in the log that don't read like they are relevant, but actually might be the root cause.

--
JeffG

aclight | Wed, 2008-06-25 10:56

This ended up being pretty long, so I sent it as an email attachment to support@activestate.com

Thanks for helping get this one figured out!
Adam

jeffg | Wed, 2008-07-02 10:58

I've added the relevant error to this bug:

http://bugs.activestate.com/show_bug.cgi?id=78232

This seems to be a side effect of the php variable sorting we added to 4.4; we are working on a fix for this issue and some performance problems related to this feature, targeted at a 4.4.1 point release. Thanks again for the info, sorry I didn't get back to you right away.

--
JeffG