Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 357403

Summary: StringIndexOutOfBounds exception viewing monitor information in the Debug view
Product: [Eclipse Project] JDT Reporter: Michael Rennie <Michael_Rennie>
Component: DebugAssignee: Michael Rennie <Michael_Rennie>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.6   
Target Milestone: 3.8 M3   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
fix none

Description Michael Rennie CLA 2011-09-12 14:31:20 EDT
Version: 3.8.0
Build id: I20110823-0925

Trying to debug a dead-lock bug I turned on "Show Monitors" in the debug view and suspended the target I was interested in. As I began to drill down into a suspended thread to see what locks it held I got the following exception:

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(Unknown Source)
	at org.eclipse.jdt.internal.debug.core.model.JDIReferenceType.getTypeName(JDIReferenceType.java:264)
	at org.eclipse.jdt.internal.debug.core.model.JDIReferenceType.getGenericName(JDIReferenceType.java:235)
	at org.eclipse.jdt.internal.debug.core.model.JDIObjectValue.getReferenceTypeName(JDIObjectValue.java:341)
	at org.eclipse.jdt.internal.debug.ui.JDIModelPresentation.getValueText(JDIModelPresentation.java:436)
	at org.eclipse.jdt.internal.debug.ui.JDIModelPresentation.getJavaContendedMonitorText(JDIModelPresentation.java:291)
	at org.eclipse.jdt.internal.debug.ui.JDIModelPresentation.getText(JDIModelPresentation.java:234)
	at org.eclipse.debug.internal.ui.LazyModelPresentation.getText(LazyModelPresentation.java:185)
	at org.eclipse.debug.internal.ui.DelegatingModelPresentation.getText(DelegatingModelPresentation.java:158)
	at org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider.getLabel(DebugElementLabelProvider.java:35)
	at org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider.getLabel(ElementLabelProvider.java:312)
	at org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider.retrieveLabel(ElementLabelProvider.java:215)
	at org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider$LabelUpdater.run(ElementLabelProvider.java:160)
	at org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider$LabelJob.run(ElementLabelProvider.java:74)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 1 Michael Rennie CLA 2011-09-15 14:39:04 EDT
The problem is two-fold:

1. I had manually suspended the debug target, meaning object information is not available

2. this causes the value of '<unknown>' to be passed around as native object names, which is what is causing the SIOOBE because we think it is a generic signature.
Comment 2 Michael Rennie CLA 2011-09-15 15:31:56 EDT
Created attachment 203441 [details]
fix
Comment 3 Michael Rennie CLA 2011-09-20 13:19:35 EDT
Pushed changes to master.
Comment 4 Dani Megert CLA 2011-10-03 11:57:43 EDT
This fix is not good. I now get "null null" displayed as value in the 'Variables' view.


Test case:
1. paste:
	public static void main(String[] args) {
		Object a= null;
		System.out.println(a);
	}
2. set breakpoint on second line in body
3. Debug
Comment 5 Michael Rennie CLA 2011-10-05 10:22:27 EDT
pushed updated fix + regression tests to master.

Please verify Curtis.
Comment 6 Dani Megert CLA 2011-10-12 05:54:33 EDT
>JDT / Platform Debug would also like to contribute to a re-build. We are tagged 
>and ready to go.
Did that not work? I still see the bug in I20111011-1046. Works in N20111011-2000.
Comment 7 Michael Rennie CLA 2011-10-12 09:43:19 EDT
(In reply to comment #6)
> >JDT / Platform Debug would also like to contribute to a re-build. We are tagged 
> >and ready to go.
> Did that not work? I still see the bug in I20111011-1046. Works in
> N20111011-2000.

Chatting with Kim, apparently my email did not make it to her prior to the build starting, so the fix is *not* in the I-build.
Comment 8 Michael Rennie CLA 2011-10-28 11:55:20 EDT
verified in I20111027-1800

As a note, a good test case to verify the fix is to follow the steps from bug 345298, and once the deadlock occurs - in your target workspace - suspend the VM in your host.