Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 370199 - [xtext][ui] Assertion failed in spell checker
Summary: [xtext][ui] Assertion failed in spell checker
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.3.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-31 06:02 EST by Sebastian Zarnekow CLA
Modified: 2017-09-19 17:37 EDT (History)
1 user (show)

See Also:
sebastian.zarnekow: juno+


Attachments
Cope with outdated cached positions (1.92 KB, patch)
2012-02-10 07:14 EST, Jan Koehnlein CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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