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

Bug 500832

Summary: [Win32] StringIndexOutOfBoundsException below Table.wmNotifyChild (thrown in String.getChars)
Product: [Eclipse Project] Platform Reporter: EPP Error Reports <error-reports-inbox>
Component: SWTAssignee: Niraj Modi <niraj.modi>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, eclipse, niraj.modi
Version: 4.5.2Keywords: triaged
Target Milestone: 4.7.1   
Hardware: All   
OS: Windows All   
See Also: https://git.eclipse.org/r/101293
https://git.eclipse.org/r/102581
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=aeb34d530d5752c1b765fc30cc81a7ae32768b82
Whiteboard:

Description EPP Error Reports CLA 2016-09-05 04:07:15 EDT
I just found this error in my weekly report. It does not look like a problem in the EPP error reporting client. Thus, I moved it to SWT. I have, however, no steps-to-reproduce. I hope that SWT committers can spot the issue by analyzing the source code.

If not, please close as WORKSFORME.




The following problem was reported via the automated error reporting:

Message: Unhandled event loop exception
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.getChars(null:-1)
    at org.eclipse.swt.widgets.Table.wmNotifyChild(Table.java:6896)
    at org.eclipse.swt.widgets.Control.wmNotify(Control.java:5704)
    at org.eclipse.swt.widgets.Composite.wmNotify(Composite.java:1956)
    at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:5256)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4732)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
    at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1633)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2117)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5063)
    at org.eclipse.swt.internal.win32.OS.CallWindowProcW(OS.java:-2)
    at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2443)
    at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:578)
    at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:444)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4774)
    at org.eclipse.swt.widgets.Table.windowProc(Table.java:5994)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5063)
    at org.eclipse.swt.internal.win32.OS.PeekMessageW(OS.java:-2)
    at org.eclipse.swt.internal.win32.OS.PeekMessage(OS.java:3141)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3764)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:827)
    at org.eclipse.jface.window.Window.open(Window.java:803)
    at org.eclipse.epp.internal.logging.aeri.ide.handlers.OpenSystemSetupWizardHandler.execute(OpenSystemSetupWizardHandler.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(null:-2)
    at sun.reflect.NativeMethodAccessorImpl.invoke(null:-1)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(null:-1)
    at java.lang.reflect.Method.invoke(null:-1)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)



Bundles:
| org.eclipse.e4.core.di | 1.5.0.v20150421-2214 | 1.5.0.v20150421-2214 |
| org.eclipse.epp.logging.aeri.ide | 1.100.0.v20160217-0435 | 1.100.0.v20160217-0435 |
| org.eclipse.jface | 3.11.1.v20160128-1644 | 3.11.1.v20160128-1644 |
| org.eclipse.swt | 3.104.2.v20160212-1350 | 3.104.2.v20160212-1350 |

Operating Systems:
| Windows | 6.1.0 | 6.1.0 |


The above information is a snapshot of the collected data. Visit https://dev.eclipse.org/recommenders/committers/aeri/v2/#!/problems/57c6a7b2e4b0a70b6a27e8d0 for the latest data.

Thank you for your assistance.
 Your friendly error-reports-inbox.


Created on behalf of marcel.bruch@xxxxxx.xxx
Comment 1 Niraj Modi CLA 2017-07-14 06:30:44 EDT
*** Bug 519610 has been marked as a duplicate of this bug. ***
Comment 2 Niraj Modi CLA 2017-07-14 06:33:05 EDT
Summarizing the investigation already done for this issue from bug 519610#c1:
Yes, going by the code of Table.wmNotifyChild() method it very likely that if plvfi.cchTextMax is 0, then we will end-up with a negative length of -1 in below expression.
int length = Math.min (string.length (), plvfi.cchTextMax - 1);

Which will lead to  StringIndexOutOfBoundsException at below line:
string.getChars (0, length, buffer, 0);

Need to add necessary checks to avoid negative length value, will share a gerrit shortly.
Comment 3 Eclipse Genie CLA 2017-07-14 12:11:26 EDT
New Gerrit change created: https://git.eclipse.org/r/101293
Comment 4 Niraj Modi CLA 2017-07-17 06:30:23 EDT
(In reply to Eclipse Genie from comment #3)
> New Gerrit change created: https://git.eclipse.org/r/101293

Pushed the above gerrit patch to master, here is the corresponding git commit:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=34821480d44d654541f3b283b235bac2b5233a3c
Comment 5 Niraj Modi CLA 2017-08-01 05:23:12 EDT
Since this is automatic error reporting issue, post 4.8 M1 we will consider back-porting it to 4.7.1
Comment 6 Niraj Modi CLA 2017-08-07 04:13:15 EDT
(In reply to Niraj Modi from comment #5)
> Since this is automatic error reporting issue, post 4.8 M1 we will consider
> back-porting it to 4.7.1

Reopening for back-port to 4.7.1
Comment 7 Eclipse Genie CLA 2017-08-07 04:22:30 EDT
New Gerrit change created: https://git.eclipse.org/r/102581
Comment 9 Niraj Modi CLA 2017-08-07 04:44:24 EDT
(In reply to Eclipse Genie from comment #8)
> Gerrit change https://git.eclipse.org/r/102581 was merged to
> [R4_7_maintenance].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=aeb34d530d5752c1b765fc30cc81a7ae32768b82

Fix back-ported to R4_7_maintenance branch, resolving now.
Comment 10 Niraj Modi CLA 2017-08-24 07:23:28 EDT
Verified by code inspection.