Project: aptanastudio
Issue APSTUD-7330: Deadlock when updating folding structure.
Got into deadlock when making performance improvements on the partitioning (i.e.: the faster partitioner made this race-condition appear). The problem is that we have paths that lock onto the editor and document in different orders. See stack below: {code} Thread [main] (Suspended)	JSSourceEditor(AbstractTextEditor).enableSanityChecking(boolean) line: 4848	<-- trying to lock on editor	AbstractTextEditor$3.run() line: 434	AbstractTextEditor$ElementStateListener.execute(Runnable, boolean) line: 599	AbstractTextEditor$ElementStateListener.elementDirtyStateChanged(Object, boolean) line: 438	TextFileDocumentProvider$FileBufferListener.dirtyStateChanged(IFileBuffer, boolean) line: 288	TextFileBufferManager$3.run() line: 706	SafeRunner.run(ISafeRunnable) line: 42	ResourceTextFileBufferManager(TextFileBufferManager).fireDirtyStateChanged(IFileBuffer, boolean) line: 704	ResourceTextFileBuffer$DocumentListener.documentChanged(DocumentEvent) line: 77	SynchronizableDocument(AbstractDocument).doFireDocumentChanged2(DocumentEvent) line: 769	SynchronizableDocument(AbstractDocument).doFireDocumentChanged(DocumentEvent, boolean, IRegion) line: 736	SynchronizableDocument(AbstractDocument).doFireDocumentChanged(DocumentEvent) line: 721	SynchronizableDocument(AbstractDocument).fireDocumentChanged(DocumentEvent) line: 796	SynchronizableDocument(AbstractDocument).replace(int, int, String, long) line: 1191	SynchronizableDocument.replace(int, int, String, long) line: 194	<-- locked on document object	SynchronizableDocument(AbstractDocument).replace(int, int, String) line: 1210	SynchronizableDocument.replace(int, int, String) line: 180	ProjectionTextStore.replace(int, int, String) line: 111	ProjectionDocument(AbstractDocument).replace(int, int, String, long) line: 1184	ProjectionDocument(AbstractDocument).replace(int, int, String) line: 1210	ProjectionDocument.replace(int, int, String) line: 629	DefaultDocumentAdapter.replaceTextRange(int, int, String) line: 248	StyledText.modifyContent(Event, boolean) line: 7180	StyledText.sendKeyEvent(Event) line: 7994	Daemon Thread [com.aptana.editor.common.text.reconciler.CommonReconciler] (Suspended)	SynchronizableDocument.removePosition(String, Position) line: 249	<-- trying to lock on document	SynchronizableDocument(AbstractDocument).removePosition(Position) line: 1124	ProjectionAnnotationModel(AnnotationModel).removePosition(IDocument, Position) line: 492	ProjectionAnnotationModel(AnnotationModel).removeAnnotation(Annotation, boolean) line: 857	ProjectionAnnotationModel(AnnotationModel).replaceAnnotations(Annotation[], Map, boolean) line: 409	ProjectionAnnotationModel.modifyAnnotations(Annotation[], Map, Annotation[]) line: 177	JSSourceEditor(AbstractFoldingEditor).updateFoldingStructure(Map) line: 173	<-- locked on editor	CommonReconcilingStrategy.updatePositions() line: 225	CommonReconcilingStrategy.calculatePositions(boolean, IProgressMonitor, IParseRootNode) line: 183	CommonReconcilingStrategy.reconcile(boolean, boolean) line: 256	CommonReconcilingStrategy.reconcile(boolean) line: 231	CommonReconcilingStrategy.fullReconcile() line: 437	CompositeReconcilingStrategy.fullReconcile() line: 125	CommonReconciler.process(DirtyRegion) line: 162	AbstractReconciler$BackgroundThread.run() line: 206	{code}
Story points: 8