Bug 406663 - [implementation] ConcurrentModificationException at org.eclipse.jface.text.AbstractDocument.getPositions()
Summary: [implementation] ConcurrentModificationException at org.eclipse.jface.text.Ab...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7.1   Edit
Hardware: All All
: P5 minor with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: needinfo, test
: 476582 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-04-26 09:52 EDT by Claudia Hwang CLA
Modified: 2020-02-06 15:09 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Claudia Hwang CLA 2013-04-26 09:52:11 EDT
Intermittent junit test failure in our continuous build. The unit test in question creates a new text resource with initial content and opens it in a text editor. We see this exception about once or twice a month (we have about 10 builds daily).

eclipse.buildId=M20110909-1335


java.util.ConcurrentModificationException
at java.util.ArrayList$SubList.checkForComodification(ArrayList.java:1129)
at java.util.ArrayList$SubList.listIterator(ArrayList.java:1009)
at java.util.AbstractList.listIterator(AbstractList.java:299)
at java.util.ArrayList$SubList.iterator(ArrayList.java:1005)
at org.eclipse.jface.text.AbstractDocument.getPositions(AbstractDocument.java:1752)
at org.eclipse.jface.text.source.AnnotationModel.getRegionAnnotationIterator(AnnotationModel.java:738)
at org.eclipse.jface.text.source.AnnotationModel.getAnnotationIterator(AnnotationModel.java:700)
at org.eclipse.jface.text.source.AnnotationRulerColumn.doPaint(AnnotationRulerColumn.java:637)
at org.eclipse.jface.text.source.AnnotationRulerColumn.doubleBufferPaint(AnnotationRulerColumn.java:543)
at org.eclipse.jface.text.source.AnnotationRulerColumn.redraw(AnnotationRulerColumn.java:824)
at org.eclipse.jface.text.source.AnnotationRulerColumn$6.run(AnnotationRulerColumn.java:807)
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:4140)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
Comment 1 Dani Megert CLA 2013-04-29 03:20:17 EDT
Can you provide the test case that fails?

Does it also fail with our latest build
http://download.eclipse.org/eclipse/downloads/drops4/S-4.3M6-201303141330/ ?
Comment 2 Claudia Hwang CLA 2013-04-29 04:18:26 EDT
We have not tried upgrading to Eclipse 4.3. We are building a fairly complex product, which we release to customers, and upgrading to Eclipse 4 is much further down on our product backlog.

As for the test case, we used SWTBot to implement this integration test. It
1) Creates a project in the workspace
2) Creates a resource within the project using a New Resource dialogue (our own implementation). The type of this resource is defined via our own extension point, and initial content for this resource is provided using the extension point.
3) The new resource is then immediately opened in a org.eclipse.ui.editors.text.TextEditor

We are not able to provide you with the implementation for this since our code is not open source.
Comment 3 Claudia Hwang CLA 2013-05-01 04:57:47 EDT
The test failure happened again today, this time on Linux.

The ConcurrentModificationException does not actually happen straight after opening the TextEditor as I previously thought. It happens after we delete the resource and the project without closing the TextEditor first. 

So the test case:
1) Creates a project in the workspace
2) Creates a resource within the project using a New Resource dialogue (our own implementation). The type of this resource is defined via our own extension point, and initial content for this resource is provided using the extension point.
3) The new resource is then immediately opened in a org.eclipse.ui.editors.text.TextEditor
4) Resource is deleted from the project without closing the text editor.
5) Project is deleted from workspace
Comment 4 Michael Seele CLA 2014-11-28 06:04:24 EST
I can verify this bug with R-4.4.1-201409250400.

We use a org.eclipse.jface.text.source.projection.ProjectionViewer.ProjectionViewer with syntax highlighting and error annotations in a simple standalone swt/jface application.

When i get this exception the input parameters of method org.eclipse.jface.text.AbstractDocument.getPositions are like that:
category = "__dflt_position_category"
offset = 0	
length = 526	
canStartBefore = true	
canEndAfter = true
Comment 5 Dani Megert CLA 2014-11-28 07:03:26 EST
(In reply to Michael Seele from comment #4)
> I can verify this bug with R-4.4.1-201409250400.
> 
> We use a
> org.eclipse.jface.text.source.projection.ProjectionViewer.ProjectionViewer
> with syntax highlighting and error annotations in a simple standalone
> swt/jface application.
> 
> When i get this exception the input parameters of method
> org.eclipse.jface.text.AbstractDocument.getPositions are like that:
> category = "__dflt_position_category"
> offset = 0	
> length = 526	
> canStartBefore = true	
> canEndAfter = true

Can you attach a test case / app?
Comment 6 Michael Seele CLA 2014-11-28 07:50:39 EST
I've found the problem: 
The org.eclipse.jface.text.source.AnnotationRulerColumn doesn't have a syncronized(fModel.getLockObject){} block around the annotation iterator (From line 725 to 753). 

Our org.eclipse.jface.text.reconciler.IReconcilingStrategy run's in the seperate thread from org.eclipse.jface.text.reconciler.MonoReconciler. We have a synchronized block around updating(remove/add) the annotations. But if the AnnotationRulerColumn makes no use of the org.eclipse.jface.text.source.AnnotationModel.getLockObject(), our synchronized block is useless.

Until this bug is fixed, we now add/remove annotations only in the ui thread as workaround.
Comment 7 Noopur Gupta CLA 2015-09-04 02:19:50 EDT
*** Bug 476582 has been marked as a duplicate of this bug. ***
Comment 8 Andrey Loskutov CLA 2016-01-31 04:27:38 EST
Just seen this error in the log on 4.6 M5 (no idea how to reproduce):

java.util.ConcurrentModificationException
	at java.util.ArrayList$SubList$1.checkForComodification(ArrayList.java:1205)
	at java.util.ArrayList$SubList$1.next(ArrayList.java:1106)
	at org.eclipse.jface.text.AbstractDocument.getPositions(AbstractDocument.java:1616)
	at org.eclipse.jface.text.source.AnnotationModel.getRegionAnnotationIterator(AnnotationModel.java:714)
	at org.eclipse.jface.text.source.AnnotationModel.getAnnotationIterator(AnnotationModel.java:676)
	at org.eclipse.jface.text.source.AnnotationRulerColumn.doPaint1(AnnotationRulerColumn.java:749)
	at org.eclipse.jface.text.source.AnnotationRulerColumn.doubleBufferPaint(AnnotationRulerColumn.java:555)
	at org.eclipse.jface.text.source.AnnotationRulerColumn.access$3(AnnotationRulerColumn.java:531)
	at org.eclipse.jface.text.source.AnnotationRulerColumn$1.paintControl(AnnotationRulerColumn.java:270)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:230)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4494)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1339)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1363)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1348)
	at org.eclipse.swt.widgets.Control.gtk_expose_event(Control.java:3283)
	at org.eclipse.swt.widgets.Composite.gtk_expose_event(Composite.java:778)
	at org.eclipse.swt.widgets.Canvas.gtk_expose_event(Canvas.java:181)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1983)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:5740)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4730)
	at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:9485)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1225)
	at org.eclipse.swt.internal.gtk.OS._gdk_window_process_all_updates(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gdk_window_process_all_updates(OS.java:6065)
	at org.eclipse.swt.widgets.Display.update(Display.java:4682)
	at org.eclipse.swt.widgets.Display.runDeferredLayouts(Display.java:3858)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3430)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1118)
Comment 9 Tom Principaal CLA 2016-02-02 04:09:03 EST
Hi there,
Is there any outlook for a fix based on the Exception stack? This bug can result in the loss of work for developers (in my case for Rational Developer for System z).
Greetingz, Tom
Comment 10 Dani Megert CLA 2016-02-02 08:49:32 EST
(In reply to Tom Principaal from comment #9)
> This bug can
> result in the loss of work for developers (in my case for Rational Developer
> for System z).
> Greetingz, Tom

Do you have steps for that?
Comment 11 Eclipse Genie CLA 2020-02-06 15:09:14 EST
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.