Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 452141 - IllegalArgumentException in TextLayout._getOffset (IME.WM_IME_COMPOSITION)
Summary: IllegalArgumentException in TextLayout._getOffset (IME.WM_IME_COMPOSITION)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.5   Edit
Hardware: PC Windows 8
: P3 critical (vote)
Target Milestone: 4.6 RC1   Edit
Assignee: Niraj Modi CLA
QA Contact: Thomas Singer CLA
URL:
Whiteboard:
Keywords:
: 283286 476929 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-11-18 11:05 EST by Thomas Singer CLA
Modified: 2017-07-14 08:15 EDT (History)
4 users (show)

See Also:
arunkumar.thondapu: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Singer CLA 2014-11-18 11:05:39 EST
We've got following bug reported multiple times by users of SmartGit 6.5 which uses SWT 4.4.0:

java.lang.IllegalArgumentException
	at org.eclipse.swt.SWT.error(SWT.java:4422)
	at org.eclipse.swt.SWT.error(SWT.java:4356)
	at org.eclipse.swt.SWT.error(SWT.java:4327)
	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2095)
	at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2354)
	at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3650)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8509)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8500)
	at org.eclipse.swt.custom.StyledText.updateSelection(StyledText.java:10342)
	at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:6253)
	at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:5643)
	at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:71)
	at org.eclipse.swt.custom.DefaultContent.sendTextEvent(DefaultContent.java:797)
	at org.eclipse.swt.custom.DefaultContent.replaceTextRange(DefaultContent.java:790)
	at org.eclipse.swt.custom.StyledText.handleCompositionChanged(StyledText.java:5827)
	at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5689)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
	at org.eclipse.swt.widgets.IME.WM_IME_COMPOSITION(IME.java:387)
	at org.eclipse.swt.widgets.Canvas.WM_IME_COMPOSITION(Canvas.java:366)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4636)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5023)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)

Unfortunately, I have no snippet or steps to reproduce.
Comment 1 Thomas Singer CLA 2014-11-18 11:08:07 EST
A similar exception has slightly different line numbers at the StyledText.handleCompositionChanged and IME.WM_IME_COMPOSITION lines:

java.lang.IllegalArgumentException
	at org.eclipse.swt.SWT.error(SWT.java:4422)
	at org.eclipse.swt.SWT.error(SWT.java:4356)
	at org.eclipse.swt.SWT.error(SWT.java:4327)
	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2095)
	at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2354)
	at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3650)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8509)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8500)
	at org.eclipse.swt.custom.StyledText.updateSelection(StyledText.java:10342)
	at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:6253)
	at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:5643)
	at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:71)
	at org.eclipse.swt.custom.DefaultContent.sendTextEvent(DefaultContent.java:797)
	at org.eclipse.swt.custom.DefaultContent.replaceTextRange(DefaultContent.java:790)
	at org.eclipse.swt.custom.StyledText.handleCompositionChanged(StyledText.java:5832)
	at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5689)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
	at org.eclipse.swt.widgets.IME.WM_IME_COMPOSITION(IME.java:505)
	at org.eclipse.swt.widgets.Canvas.WM_IME_COMPOSITION(Canvas.java:366)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4636)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5023)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
Comment 2 Thomas Singer CLA 2015-01-28 12:42:12 EST
This error is one of the most reported bugs for SmartGit (78 crash logs, 20 more detailled reports). Hence, I'm increasing the importance.
Comment 3 Thomas Singer CLA 2015-07-02 02:30:41 EDT
That is a stacktrace using SWT 4.5M7:

java.lang.IllegalArgumentException
	at org.eclipse.swt.SWT.error(SWT.java:4472)
	at org.eclipse.swt.SWT.error(SWT.java:4406)
	at org.eclipse.swt.SWT.error(SWT.java:4377)
	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2095)
	at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2354)
	at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3669)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8554)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8545)
	at org.eclipse.swt.custom.StyledText.updateSelection(StyledText.java:10404)
	at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:6262)
	at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:5662)
	at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:71)
	at org.eclipse.swt.custom.DefaultContent.sendTextEvent(DefaultContent.java:796)
	at org.eclipse.swt.custom.DefaultContent.replaceTextRange(DefaultContent.java:789)
	at org.eclipse.swt.custom.StyledText.handleCompositionChanged(StyledText.java:5851)
	at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5708)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
	at org.eclipse.swt.widgets.IME.WM_IME_COMPOSITION(IME.java:508)
	at org.eclipse.swt.widgets.Canvas.WM_IME_COMPOSITION(Canvas.java:366)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4680)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5050)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3767)
	at com.syntevo.q.gui.QSwt.dispatchEvents(SourceFile:305)
	at com.syntevo.smartgit.SaApplicationStarter.openGui(SourceFile:323)
	at com.syntevo.smartgit.SaApplicationStarter.parse(SourceFile:210)
	at com.syntevo.sc.application.ScParsingApplicationStarter.start(SourceFile:62)
	at SmartGit.main(SourceFile:11)
Comment 4 Arun Thondapu CLA 2015-07-02 06:39:15 EDT
Hard to fix without any reproducible scenario but one possible harmless fix that might help is to change line 3666 in StyledText.java from 

int offsetInLine = offset - lineOffset; 

to 

int offsetInLine = Math.max (0, offset - lineOffset);

Thomas, do you think it is possible to test this change in SmartGit's SWT bundle and confirm before we actually integrate it in a release?
Comment 5 Thomas Singer CLA 2015-07-02 10:19:08 EDT
Unfortunately, no user has provided reproducible steps. I want to avoid building SWT myself.
Comment 6 Niraj Modi CLA 2015-07-09 09:18:58 EDT
Current SWT error stack-trace doesn't print the 'offset' value, we don't know if it's going negative or greater than text array length.
Detailed the SWT error with 'offset' value in TextLayout._getOffset(), vai below git commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=aa5e1f529d6cb38f7ba5b2ed1cb51812ef434823

Thomas: Please share/attach stack-trace(s) with offset information.
Comment 7 Niraj Modi CLA 2015-09-10 04:33:17 EDT
Slightly different stack-trace:
https://dev.eclipse.org/recommenders/committers/confess/#/problems/55d5737be4b0f0b83a6e67b8/details

java.lang.IllegalArgumentException: Index out of bounds
at org.eclipse.swt.SWT.error(SWT.java:4458)
at org.eclipse.swt.SWT.error(SWT.java:4392)
at org.eclipse.swt.SWT.error(SWT.java:4363)
at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2095)
at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2354)
at org.eclipse.swt.custom.StyledText.getPointAtOffset(StyledText.java:5474)
at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8556)
at org.eclipse.swt.custom.StyledText.scrollHorizontal(StyledText.java:8039)
at org.eclipse.swt.custom.StyledText.claimRightFreeSpace(StyledText.java:1682)
at org.eclipse.swt.custom.StyledText.handleResize(StyledText.java:6218)
at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5694)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
Comment 8 Niraj Modi CLA 2015-09-10 04:50:49 EDT
(In reply to Niraj Modi from comment #6)
> Current SWT error stack-trace doesn't print the 'offset' value, we don't
> know if it's going negative or greater than text array length.
> Detailed the SWT error with 'offset' value in TextLayout._getOffset(), vai
> below git commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=aa5e1f529d6cb38f7ba5b2ed1cb51812ef434823
> 
> Thomas: Please share/attach stack-trace(s) with offset information.

Going by the code it highly possible that below method call which is common across all stack-trace, is getting called with negative 'offset' value only and same gets passed to TextLayout._getOffset() and is leading to this problem:
org.eclipse.swt.graphics.TextLayout.getPreviousOffset(int offset, int movement)

Working on a fix by adding a lower-cap of 0 to 'offset' value(as suggested in comment 4 by Arun) at below method calls in StyledText class:
- StyledText.getBoundsAtOffset()
- StyledText.getPointAtOffset()
Comment 9 Eclipse Genie CLA 2015-09-10 04:55:44 EDT
New Gerrit change created: https://git.eclipse.org/r/55623
Comment 11 Niraj Modi CLA 2015-09-11 03:50:46 EDT
Resolving.
Comment 12 Sarika Sinha CLA 2015-09-11 06:53:40 EDT
*** Bug 476929 has been marked as a duplicate of this bug. ***
Comment 14 Niraj Modi CLA 2015-09-15 06:57:35 EDT
(In reply to Thomas Singer from comment #5)
> Unfortunately, no user has provided reproducible steps. I want to avoid
> building SWT myself.

Hi Thomas,
Going by various stack-traces available, we have made required changes.
Can you try 4.6 M2 build & see if it fixes the problem in your product ?
Comment 15 Thomas Singer CLA 2015-09-17 03:07:07 EDT
I've built our new SWT jars from the latest code and released them with the latest preview build. It will take some time to verify that the problem has been solved by not occurring exceptions.
Comment 16 Thomas Singer CLA 2016-02-05 03:25:02 EST
We are still getting reports with SWT 4.610:

java.lang.IllegalArgumentException
	at org.eclipse.swt.SWT.error(SWT.java:4484)
	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2102)
	at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2361)
	at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3670)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8555)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8546)
	at org.eclipse.swt.custom.StyledText.updateSelection(StyledText.java:10405)
	at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:6263)
	at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:5663)
	at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:71)
	at org.eclipse.swt.custom.DefaultContent.sendTextEvent(DefaultContent.java:797)
	at org.eclipse.swt.custom.DefaultContent.replaceTextRange(DefaultContent.java:790)
	at org.eclipse.swt.custom.StyledText.handleCompositionChanged(StyledText.java:5847)
	at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5709)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:85)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4373)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1137)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1122)
	at org.eclipse.swt.widgets.IME.WM_IME_COMPOSITION(IME.java:389)
	at org.eclipse.swt.widgets.Canvas.WM_IME_COMPOSITION(Canvas.java:373)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4710)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:344)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5061)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3777)
...

Unfortunately, no user has yet provided exact steps how to reproduce.
Comment 17 Niraj Modi CLA 2016-03-21 07:09:04 EDT
(In reply to Thomas Singer from comment #16)
> We are still getting reports with SWT 4.610:
> 
> java.lang.IllegalArgumentException
> 	at org.eclipse.swt.SWT.error(SWT.java:4484)
> 	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2102)
> 	at
> org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2361)
> 	at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3670)
> 	at 
> ...
Hi Thomas,
Fix in comment 10 already has a check in StyledText.getBoundsAtOffset()
which should have avoided above stack-trace for negative offsets.
Can you please confirm if this stack-trace occurred with my fix and has over-shot value which is non-negative ?
Also I have already updated the logging mechanism(commit in comment 6) to print the offset in the log which should look something like below(for offset value -1):
java.lang.IllegalArgumentException: Index out of bounds [offset value: -1]
	at org.eclipse.swt.SWT.error(SWT.java:4514)
	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2144)
	at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2410)
	at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3700)

> Unfortunately, no user has yet provided exact steps how to reproduce.
Keep looking for so that we could fix the root cause and not the symptoms.
Comment 18 Thomas Singer CLA 2016-03-21 13:05:19 EDT
(In reply to Niraj Modi from comment #17)
> Also I have already updated the logging mechanism(commit in comment 6) to
> print the offset in the log which should look something like below(for
> offset value -1):
> java.lang.IllegalArgumentException: Index out of bounds [offset value: -1]
> 	at org.eclipse.swt.SWT.error(SWT.java:4514)
> 	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2144)
> 	at
> org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2410)
> 	at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3700)

Unfortunately, nearly all of our exceptions we get from users don't contain a message because of potential sensitive data being sent. The full data only is available if the user accepts to send the full log.
Comment 19 Thomas Singer CLA 2016-03-21 13:17:23 EDT
Luckily a few users have reported full logs. The exception message looks like:

java.lang.IllegalArgumentException: Index out of bounds [offset value: 8]
	at org.eclipse.swt.SWT.error(SWT.java:4484)
	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2102)
	at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2361)

or

java.lang.IllegalArgumentException: Index out of bounds [offset value: 15]
	at org.eclipse.swt.SWT.error(SWT.java:4484)
	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2102)
	at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2361)
Comment 20 Thomas Singer CLA 2016-03-21 13:20:39 EDT
Could it be related to bug 481814?
Comment 21 Niraj Modi CLA 2016-05-02 10:19:08 EDT
(In reply to Thomas Singer from comment #20)
> Could it be related to bug 481814?

No, this looks like a different issue.

(In reply to Thomas Singer from comment #19)
> Luckily a few users have reported full logs. The exception message looks
> like:
> 
> java.lang.IllegalArgumentException: Index out of bounds [offset value: 8]
> 	at org.eclipse.swt.SWT.error(SWT.java:4484)
> 	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2102)
> 	at
> org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2361)
> 
> or
> 
> java.lang.IllegalArgumentException: Index out of bounds [offset value: 15]
> 	at org.eclipse.swt.SWT.error(SWT.java:4484)
> 	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2102)
> 	at
> org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2361)

Hi Thomas,
There is no clean solution for above, only thing we can do is add appropriate checks in code to avoid these scenario(s)

If possible please share full stack-traces of above instances(which different origin in StyledText code), so we know what all places in StyledText code need to handled.

Targeting for Neon RC1
Comment 22 Thomas Singer CLA 2016-05-02 12:45:48 EDT
Here are some stacktraces from different users against SWT 4.610:

java.lang.IllegalArgumentException: Index out of bounds [offset value: 20]
	at org.eclipse.swt.SWT.error(SWT.java:4484)
	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2102)
	at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2361)
	at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3670)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8555)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8546)
	at org.eclipse.swt.custom.StyledText.updateSelection(StyledText.java:10405)
	at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:6263)
	at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:5663)
	at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:71)
	at org.eclipse.swt.custom.DefaultContent.sendTextEvent(DefaultContent.java:797)
	at org.eclipse.swt.custom.DefaultContent.replaceTextRange(DefaultContent.java:790)
	at org.eclipse.swt.custom.StyledText.handleCompositionChanged(StyledText.java:5852)
	at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5709)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:85)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4373)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1137)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1122)
	at org.eclipse.swt.widgets.IME.WM_IME_COMPOSITION(IME.java:510)
	at org.eclipse.swt.widgets.Canvas.WM_IME_COMPOSITION(Canvas.java:373)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4710)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:344)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5061)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3777)

java.lang.IllegalArgumentException: Index out of bounds [offset value: 16]
	at org.eclipse.swt.SWT.error(SWT.java:4484)
	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2102)
	at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2361)
	at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3670)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8555)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8546)
	at org.eclipse.swt.custom.StyledText.updateSelection(StyledText.java:10405)
	at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:6263)
	at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:5663)
	at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:71)
	at org.eclipse.swt.custom.DefaultContent.sendTextEvent(DefaultContent.java:797)
	at org.eclipse.swt.custom.DefaultContent.replaceTextRange(DefaultContent.java:790)
	at org.eclipse.swt.custom.StyledText.handleCompositionChanged(StyledText.java:5847)
	at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5709)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:85)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4373)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1137)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1122)
	at org.eclipse.swt.widgets.IME.WM_IME_COMPOSITION(IME.java:389)
	at org.eclipse.swt.widgets.Canvas.WM_IME_COMPOSITION(Canvas.java:373)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4710)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:344)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5061)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3777)

java.lang.IllegalArgumentException: Index out of bounds [offset value: 12]
	at org.eclipse.swt.SWT.error(SWT.java:4484)
	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2102)
	at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2361)
	at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3670)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8555)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8546)
	at org.eclipse.swt.custom.StyledText.updateSelection(StyledText.java:10405)
	at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:6263)
	at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:5663)
	at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:71)
	at org.eclipse.swt.custom.DefaultContent.sendTextEvent(DefaultContent.java:797)
	at org.eclipse.swt.custom.DefaultContent.replaceTextRange(DefaultContent.java:790)
	at org.eclipse.swt.custom.StyledText.handleCompositionChanged(StyledText.java:5847)
	at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5709)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:85)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4373)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1137)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1122)
	at org.eclipse.swt.widgets.IME.WM_IME_COMPOSITION(IME.java:510)
	at org.eclipse.swt.widgets.Canvas.WM_IME_COMPOSITION(Canvas.java:373)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4710)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:344)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5061)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3777)

java.lang.IllegalArgumentException: Index out of bounds [offset value: 24]
	at org.eclipse.swt.SWT.error(SWT.java:4484)
	at org.eclipse.swt.graphics.TextLayout._getOffset(TextLayout.java:2102)
	at org.eclipse.swt.graphics.TextLayout.getPreviousOffset(TextLayout.java:2361)
	at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3670)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8555)
	at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8546)
	at org.eclipse.swt.custom.StyledText.updateSelection(StyledText.java:10405)
	at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:6263)
	at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:5663)
	at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:71)
	at org.eclipse.swt.custom.DefaultContent.sendTextEvent(DefaultContent.java:797)
	at org.eclipse.swt.custom.DefaultContent.replaceTextRange(DefaultContent.java:790)
	at org.eclipse.swt.custom.StyledText.handleCompositionChanged(StyledText.java:5852)
	at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5709)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:85)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4373)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1137)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1122)
	at org.eclipse.swt.widgets.IME.WM_IME_COMPOSITION(IME.java:510)
	at org.eclipse.swt.widgets.Canvas.WM_IME_COMPOSITION(Canvas.java:373)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4710)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:344)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5061)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3777)
Comment 23 Niraj Modi CLA 2016-05-03 10:24:00 EDT
(In reply to Thomas Singer from comment #22)
> Here are some stacktraces from different users against SWT 4.610:
> 
Thanks for sharing these stacktraces, all of these can be handled at one common point in the code i.e. before call to TextLayout.getPreviousOffset() method in StyledText.getBoundsAtOffset() method.

Will share a gerrit on this shortly.
Comment 24 Eclipse Genie CLA 2016-05-03 10:33:31 EDT
New Gerrit change created: https://git.eclipse.org/r/71904
Comment 25 Niraj Modi CLA 2016-05-03 11:11:44 EDT
(In reply to Eclipse Genie from comment #24)
> New Gerrit change created: https://git.eclipse.org/r/71904

Hi Arun,
Neon RC1 bug, for your review.
Comment 27 Arun Thondapu CLA 2016-05-06 09:15:32 EDT
Marking as Resolved.

Thomas, can you please propagate this latest fix to your customers and verify that the problem is fixed as we're unable to reproduce the real issue at our end? Thanks!
Comment 28 Niraj Modi CLA 2017-07-14 08:15:58 EDT
*** Bug 283286 has been marked as a duplicate of this bug. ***