Bug 471809 - IllegalArgumentException in StyledText.getOffsetAtLine (4400)
Summary: IllegalArgumentException in StyledText.getOffsetAtLine (4400)
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P5 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2015-07-03 09:23 EDT by EPP Error Reports CLA
Modified: 2020-07-29 05:37 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description EPP Error Reports CLA 2015-07-03 09:23:20 EDT
The following incident was reported via the automated error reporting:


    code:                   2
    plugin:                 org.eclipse.ui.workbench_3.107.0.v20150510-1732
    message:                HIDDEN
    fingerprint:            9b4dc749
    exception class:        java.lang.IllegalArgumentException
    exception message:      HIDDEN
    number of children:     0
    
    java.lang.IllegalArgumentException: HIDDEN
    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.custom.StyledText.getOffsetAtLine(StyledText.java:4400)
    at org.eclipse.jface.text.JFaceTextUtil.getPartialTopIndex(JFaceTextUtil.java:103)
    at org.eclipse.jface.text.JFaceTextUtil.getPartialTopIndex(JFaceTextUtil.java:151)
    at org.eclipse.jface.text.JFaceTextUtil.getVisibleModelLines(JFaceTextUtil.java:176)
    at org.eclipse.jface.text.source.LineNumberRulerColumn.doubleBufferPaint(LineNumberRulerColumn.java:690)
    at org.eclipse.jface.text.source.LineNumberRulerColumn.redraw(LineNumberRulerColumn.java:850)
    at org.eclipse.ui.internal.texteditor.LineNumberColumn$2.propertyChange(LineNumberColumn.java:276)
    at org.eclipse.ui.internal.texteditor.PropertyEventDispatcher.firePropertyChange(PropertyEventDispatcher.java:47)
    at org.eclipse.ui.internal.texteditor.PropertyEventDispatcher.access$0(PropertyEventDispatcher.java:44)
    at org.eclipse.ui.internal.texteditor.PropertyEventDispatcher$1.propertyChange(PropertyEventDispatcher.java:31)
    at org.eclipse.ui.preferences.ScopedPreferenceStore$3.run(ScopedPreferenceStore.java:351)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.preferences.ScopedPreferenceStore.firePropertyChangeEvent(ScopedPreferenceStore.java:347)
    at org.eclipse.ui.preferences.ScopedPreferenceStore$2.preferenceChange(ScopedPreferenceStore.java:182)
    at org.eclipse.core.internal.preferences.EclipsePreferences$3.run(EclipsePreferences.java:896)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.preferences.EclipsePreferences.firePreferenceEvent(EclipsePreferences.java:899)
    at org.eclipse.core.internal.preferences.EclipsePreferences.put(EclipsePreferences.java:912)
    at org.eclipse.oomph.preferences.util.PreferencesUtil$PreferenceProperty.set(PreferencesUtil.java:519)
    at org.eclipse.oomph.setup.impl.PreferenceTaskImpl$1.run(PreferenceTaskImpl.java:318)
    at org.eclipse.oomph.setup.impl.SetupTaskImpl$1.run(SetupTaskImpl.java:777)
    at org.eclipse.oomph.ui.UIUtil$6.run(UIUtil.java:588)
    at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:162)
    at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:154)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3794)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3433)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
    at java.lang.reflect.Method.invoke(Method.java:620)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
   
  

General Information:

    reported-by:      
    anonymous-id:     aa6617cf-a9d2-4a8e-aeb8-f1ff4c08ddde
    eclipse-build-id: 4.5.0.I20150603-2000
    eclipse-product:  org.eclipse.epp.package.jee.product
    operating system: Linux 4.0.4.fc22 (x86_64) - gtk
    jre-version:      pxa6470_27sr3fp1-20150605_01 (SR3 FP1)

The following plug-ins were present on the execution stack (*):
    1. org.eclipse.core.databinding.observable_1.5.0.v20150422-0725
    2. org.eclipse.core.databinding_1.5.0.v20150422-0725
    3. org.eclipse.core.runtime_3.11.0.v20150405-1723
    4. org.eclipse.e4.ui.workbench_1.3.0.v20150531-1948
    5. org.eclipse.e4.ui.workbench.swt_0.13.0.v20150504-0621
    6. org.eclipse.equinox.app_1.3.300.v20150423-1356
    7. org.eclipse.equinox.launcher_1.3.100.v20150511-1540
    8. org.eclipse.jface.text_3.10.0.v20150603-1752
    9. org.eclipse.jface_3.11.0.v20150602-1400
    10. org.eclipse.oomph.preferences_1.1.0.v20150609-1259
    11. org.eclipse.oomph.setup_1.1.0.v20150610-1559
    12. org.eclipse.oomph.ui_1.1.0.v20150610-0617
    13. org.eclipse.swt_3.104.0.v20150528-0211
    14. org.eclipse.ui_3.107.0.v20150507-1945
    15. org.eclipse.ui.ide.application_1.1.0.v20150422-0725
    16. org.eclipse.ui.ide_3.11.0.v20150510-1749

Please note that:
* Messages, stacktraces, and nested status objects may be shortened.
* Bug fields like status, resolution, and whiteboard are sent
  back to reporters.
* The list of present bundles and their respective versions was
  calculated by package naming heuristics. This may or may not reflect reality.

Other Resources:
* Report: https://dev.eclipse.org/recommenders/committers/confess/#/problems/558dc4b9e4b08735226aeb55  
* Manual: https://dev.eclipse.org/recommenders/community/confess/#/guide


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

This bug was created on behalf of ed.merks@gmail.com.
Comment 1 Niraj Modi CLA 2015-07-03 09:36:10 EDT
Copying https://bugs.eclipse.org/bugs/show_bug.cgi?id=471192#c5

SWT StyledText#getOffsetAtLine(int lineIndex) is public method which throws IllegalArgumentException only when 'lineIndex' argument is out of range, which happens to be the case here.

Hard to fix without any reproducible scenario, re-assigning it to Platform-UI team for further investigation.
Comment 2 Brian de Alwis CLA 2015-07-03 10:47:54 EDT
I think this belongs to Platform Text (seems to be toggling the show-line-numbers), but it would definitely help to know the editor type and information about its contents.

One of the reporters mentioned he only uses Java and XML editors.
Comment 3 Ed Merks CLA 2015-07-04 10:58:46 EDT
It just strikes me that the SWT method itself is suspicious:

Note that whether this is a platform bug really comes down to whether this method is correct.

	public static int getPartialTopIndex(StyledText widget) {
		// see StyledText#getPartialTopIndex()
		int top= widget.getTopIndex();
		int pixels= widget.getLinePixel(top);

		// FIXME remove when https://bugs.eclipse.org/bugs/show_bug.cgi?id=123770 is fixed
		if (pixels == -widget.getLineHeight(widget.getOffsetAtLine(top))) {
			top++;
			pixels= 0;
		}

		if (pixels > 0)
			top--;

		return top;
	}

And given the stack trace, it's a question of whether this should ever throw an index out of bounds exception given widget is a StyledText widget.

  widget.getOffsetAtLine(widget.getTopIndex())

It seems to me that should not be possible.

It's interesting that this code is only there for https://bugs.eclipse.org/bugs/show_bug.cgi?id=123770 and that bug is specific to Linux, and this problem here is reported only for Linux.  All this suggest to me that the problem is in SWT.

Looking at that method:

public int getOffsetAtLine(int lineIndex) {
	checkWidget();
	if (lineIndex < 0 || 
		(lineIndex > 0 && lineIndex >= content.getLineCount())) {
		SWT.error(SWT.ERROR_INVALID_RANGE);		
	}
	return content.getOffsetAtLine(lineIndex);
}

It seems questionable that this guard should be here at all. Because looking at an implementation of getOffsetAtLine:

	public int getOffsetAtLine(int line) {
		IDocument document= getDocumentForRead();
		try {
			return document.getLineOffset(line);
		} catch (BadLocationException x) {
			repairLineInformation(document);
			try {
				return document.getLineOffset(line);
			} catch (BadLocationException x2) {
			}
		}

		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
		return -1;
	}

There seems to be some repairLineInformation call involved here.  But the guard in SWT never lets it get that far. 

And of course it's very unhelpful that the exception doesn't include information about the index/range involved.
Comment 4 Brian de Alwis CLA 2015-07-05 20:28:31 EDT
I heard back from the primary reporter and he mentioned that it happened after he'd been working with Eclipse for a while.
Comment 5 Dani Megert CLA 2015-07-22 04:47:48 EDT
I can't reproduce this. Keeping open to gather more details.
Comment 6 Eclipse Genie CLA 2020-07-29 05:37:43 EDT
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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.