Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[Dltk-dev] exception updating variable children count

hello all -

  i keep getting an exception thrown when the code tries to update the children count for python objects. i've tracked down the issue and it seems that for some values returned by the python engine, the children count is less than the available children count. the ScriptValue object's 'variables' field is initialized to be the size of 'property.getChildrenCount', and 'fillVariables' is making a call to getAvailableChildren and an ArrayOutOfBoundsException ends up being thrown b/c the 'variables' array ends up being too small.

  you can see this behavior for yourself by using the attached python script. just set a breakpoint on line 21 (myobject = getObject(1)) and then 'step over'.

  the attached patch fixes this behavior by checking to see if the 'childrenCount' of the dbgp property is less then the number of 'availableChildren' (instead of checking to see if it's less then 0), and if yes, then it sets the 'childrenCount' = availableChildren. as far as i can tell, this change does not seem to negatively impact any of the other debuggers, but perhaps there is a better solution for this.

--
-jae

Attachment: object.py
Description: Binary data

### Eclipse Workspace Patch 1.0
#P org.eclipse.dltk.debug
Index: src/org/eclipse/dltk/internal/debug/core/model/ScriptStackFrame.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptStackFrame.java,v
retrieving revision 1.17
diff -u -r1.17 ScriptStackFrame.java
--- src/org/eclipse/dltk/internal/debug/core/model/ScriptStackFrame.java	3 Jul 2008 12:18:47 -0000	1.17
+++ src/org/eclipse/dltk/internal/debug/core/model/ScriptStackFrame.java	9 Jul 2008 12:53:22 -0000
@@ -346,6 +346,10 @@
 			for (int i = 0; i < newVars.length; ++i) {
 				final IVariable variable = newVars[i];
 				final IRefreshableScriptVariable old;
+				if (variable == null) {
+					continue;
+				}
+
 				old = (IRefreshableScriptVariable) map.get(variable.getName());
 				if (old != null) {
 					newVars[i] = old.refreshVariable(variable);
Index: src/org/eclipse/dltk/dbgp/internal/utils/DbgpXmlEntityParser.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/utils/DbgpXmlEntityParser.java,v
retrieving revision 1.20
diff -u -r1.20 DbgpXmlEntityParser.java
--- src/org/eclipse/dltk/dbgp/internal/utils/DbgpXmlEntityParser.java	9 Jul 2008 12:51:57 -0000	1.20
+++ src/org/eclipse/dltk/dbgp/internal/utils/DbgpXmlEntityParser.java	9 Jul 2008 12:53:22 -0000
@@ -182,7 +182,7 @@
 					.toArray(new IDbgpProperty[childrenList.size()]);
 		}
 
-		if (childrenCount < 0) {
+		if (childrenCount < availableChildren.length) {
 			childrenCount = availableChildren.length;
 		}
 

Back to the top