| Summary: | [StyledText] DefaultContent.getLine(DefaultContent.java:489) - java.lang.StringIndexOutOfBoundsException | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Rutger Ovidius <ovidr> | ||||||
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> | ||||||
| Status: | CLOSED WONTFIX | QA Contact: | Felipe Heidrich <eclipse.felipe> | ||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | eclipse.felipe, james.willans, mlists, n.a.edgar, snorthov | ||||||
| Version: | 3.1 | Keywords: | triaged | ||||||
| Target Milestone: | --- | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows XP | ||||||||
| Whiteboard: | stalebug | ||||||||
| Attachments: |
|
||||||||
Created attachment 22778 [details]
testcase
FH, is this a candidate for RC3? I don't think we should fix this for 3.1. Really? An SIOOBE? How rude! I also receive the following stacktrace with 3.2M2 when using the scrollbar on a StyledText widget. Looks to be the same getLine problem. (This is a really bad bug that comes up a lot for me). java.lang.StringIndexOutOfBoundsException: String index out of range: -427 at java.lang.String.<init>(Unknown Source) at org.eclipse.swt.custom.DefaultContent.getLine (DefaultContent.java:487) at org.eclipse.swt.custom.StyledText$ContentWidthCache.calculate (StyledText.java:1251) at org.eclipse.swt.custom.StyledText.calculateTopIndex (StyledText.java:2002) at org.eclipse.swt.custom.StyledText.setVerticalScrollOffset (StyledText.java:7701) at org.eclipse.swt.custom.StyledText.handleVerticalScroll (StyledText.java:5443) at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:4874) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:884) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:908) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:893) at org.eclipse.swt.widgets.ScrollBar.wmScrollChild(ScrollBar.java:902) at org.eclipse.swt.widgets.Scrollable.wmScroll(Scrollable.java:394) at org.eclipse.swt.widgets.Scrollable.WM_VSCROLL(Scrollable.java:341) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3137) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3854) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1693) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2839) at sancho.view.MainWindow.<init>(MainWindow.java:186) FH, any idea about this one? Seems bad. With latest CVS (swt 3230) I receive the following different stacktrace. Any chance this will be looked at for 3.2? Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native Method) at java.lang.AbstractStringBuilder.append(Unknown Source) at java.lang.StringBuffer.append(Unknown Source) at org.eclipse.swt.custom.DefaultContent.getLine(DefaultContent.java:493) at org.eclipse.swt.custom.StyledTextRenderer.getHeight(StyledTextRenderer.java:496) at org.eclipse.swt.custom.StyledText.setScrollBars(StyledText.java:7350) at org.eclipse.swt.custom.StyledText.resetCache(StyledText.java:6307) at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:5292) at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:4785) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:66) at org.eclipse.swt.custom.DefaultContent.sendTextEvent(DefaultContent.java:794) at org.eclipse.swt.custom.DefaultContent.replaceTextRange(DefaultContent.java:787) at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:5763) at org.eclipse.swt.custom.StyledText.replaceTextRange(StyledText.java:6278) at STC.appendLine(STC.java:53) at STC.main(STC.java:46) FH, still a problem? Yes, it is still a problem. This part of the code is pretty complicated and I never touch it, I had the fix once but I decided not to release cause I was afraid of breaking eclipse. BTW, this doesn't happen on Eclipse. It was really hard to find this one. The testcase would only show the bug in the 16th iteration when the line count is over one thousand and the char count over hundred thousand. The problem actualy happens in the 2nd iteration.
Simple test case:
s.setText("abc\r");
s.append("\ndef");
At this point lineCount == 3, it should be 2, the text really is:
line0: "abc\r\n"
line1: "def"
Or,
s.setText("abc\rX\ndef");
s.replaceTextRange(4, 1, "");
At this point lineCount 3, it should be 2. The result text is same as the first case.
Still, I don't have a elegant fix for it.
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info. Created attachment 183807 [details]
Proposed patch in DefaultContent.java
Proposing a patch that solves the following three cases:
1) creating a CR+LF by inserting a LF after a CR
2) creating a CR+LF by inserting a CR before a LF
3) creating a CR+LF by deleting text between a CR and a LF
Legal Message: I, Patrick Tassé, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer to make this contribution under
the EPL.
This is a one-off bulk update. (The last one in the triage migration). Moving bugs from swt-triaged@eclipse to platform-swt-inbox@eclipse.org and adding "triaged" keyword as per new triage process: https://wiki.eclipse.org/SWT/Devel/Triage See Bug 518478 for details. Tag for notification/mail filters: @TriageBulkUpdate This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
WIN32 - SWT 3.1M4 and 3.1RC1 Resizing a composite with a StyledText contained within will ocassionally result in the following crash: (line # might be off as I've added debugging printlns). java.lang.StringIndexOutOfBoundsException: String index out of range: -927 at java.lang.String.<init>(Unknown Source) at org.eclipse.swt.custom.DefaultContent.getLine(DefaultContent.java:599) at org.eclipse.swt.custom.StyledText$ContentWidthCache.calculate(StyledText.java:1219) at org.eclipse.swt.custom.StyledText.computeSize(StyledText.java:2102) at org.eclipse.swt.layout.GridData.computeSize(GridData.java:450) at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:197) at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:155) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.swt.layout.FillLayout.computeSize(FillLayout.java:110) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.swt.widgets.Control.computeSize(Control.java:382) Quick observation: The 'gap' length in DefaultContent is positive when calculated by 'gapEnd - gapStart', but lines[2][1] has been set negative in moveAndResizeGap() which is called on insert()s and delete()s. 344: lines[gapLine][1] = lines[gapLine][1] - oldSize; getLine is using this negative value to construct a String. 482: int length = lines[index][1]; which is the called from the StyledText$ContentWidthCache.calculate() call during a resize. Attached is a testcase that appends some lines of text to a styledText and manually calls getLine(2), and crashes in a similar manner. Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -33673 at java.lang.String.<init>(Unknown Source) at org.eclipse.swt.custom.DefaultContent.getLine(DefaultContent.java:489) at STC.appendLine(STC.java:61) at STC.main(STC.java:44)