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

Bug 370199

Summary: [xtext][ui] Assertion failed in spell checker
Product: [Modeling] TMF Reporter: Sebastian Zarnekow <sebastian.zarnekow>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jan
Version: 2.3.0Flags: sebastian.zarnekow: juno+
Target Milestone: M6   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Cope with outdated cached positions none

Description Sebastian Zarnekow CLA 2012-01-31 06:02:36 EST
org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
	at org.eclipse.jface.text.Position.setLength(Position.java:185)
	at org.eclipse.xtext.ui.editor.model.DocumentPartitioner.computePartitioning(DocumentPartitioner.java:735)
	at org.eclipse.jface.text.AbstractDocument.computePartitioning(AbstractDocument.java:1430)
	at org.eclipse.jface.text.TextUtilities.computePartitioning(TextUtilities.java:431)
	at org.eclipse.xtext.ui.editor.reconciler.XtextSpellingReconcileStrategy.computePartitioning(XtextSpellingReconcileStrategy.java:72)
	at org.eclipse.xtext.ui.editor.reconciler.XtextSpellingReconcileStrategy.reconcile(XtextSpellingReconcileStrategy.java:64)
	at org.eclipse.xtext.ui.editor.reconciler.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:73)
	at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.run(XtextReconciler.java:239)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 1 Jan Koehnlein CLA 2012-02-10 07:14:19 EST
Created attachment 210847 [details]
Cope with outdated cached positions

Would be nice to have an example to reproduce this.

I assume it's a race condition, as we cache the partition positions which are calculated in 
   DocumentPartitioner.documentChanged2(DocumentEvent)
called from the UI thread and calculate the partitions from this data in 
  DocumentPartitioner.computePartitioning(int, int, boolean) 
called from the reconciler (non-UI thread). If the document is changed concurrently, the document's length no longer matches the partitions.

The code is more or less copied from existing JFace classes, so the race condition should also occur in other editors. Our caching just raises the likelyhood. 

As the concurrent document change is going to trigger another reconciler run, I guess it's safe to just ignore this condition and let the second run fix the broken partitions. The attached patch implements this. We could also try to synchronize the fCachedPositions between the two threads alternatively, but I'd rather not raise the complexity here.

Opinions?
Comment 2 Jan Koehnlein CLA 2012-02-28 08:40:55 EST
Applied patch and pushed to MASTER.
Comment 3 Karsten Thoms CLA 2017-09-19 17:25:59 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 4 Karsten Thoms CLA 2017-09-19 17:37:22 EDT
Closing all bugs that were set to RESOLVED before Neon.0