Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366784 - [Xtend] Deadlock in Xtend editor (Content Assist & Hover)
Summary: [Xtend] Deadlock in Xtend editor (Content Assist & Hover)
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Windows 7
: P3 critical (vote)
Target Milestone: M5   Edit
Assignee: Jan Koehnlein CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-15 03:30 EST by Oliver L CLA
Modified: 2017-09-19 17:52 EDT (History)
5 users (show)

See Also:
sven.efftinge: juno+


Attachments
Thread dump (10.32 KB, text/plain)
2011-12-15 03:31 EST, Oliver L CLA
no flags Details
Thread dump (text hover) (8.53 KB, text/plain)
2011-12-15 03:58 EST, Oliver L CLA
no flags Details
Avoid using accessing the UI thread in DefaultOccurrenceComputer (2.58 KB, patch)
2011-12-19 09:20 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 Oliver L CLA 2011-12-15 03:30:37 EST
Build Identifier: 

I just wanted to use Xtend editor's Content Assist. Unfortunately the UI thread doesn't respsond anymore. Threadsdump is attached.

Reproducible: Sometimes
Comment 1 Oliver L CLA 2011-12-15 03:31:06 EST
Created attachment 208422 [details]
Thread dump
Comment 2 Oliver L CLA 2011-12-15 03:58:52 EST
Created attachment 208423 [details]
Thread dump (text hover)

The problem occurs with on hover, too.
Comment 3 Knut Wannheden CLA 2011-12-15 04:17:38 EST
Yuck! Looks like the fix for bug 358396 doesn't quite cut it when you also throw content assist into the mix. So we now have the validation job, the reconciler, and the UI thread (content assist) all waiting for the occurrence marker, which in turn waits on the UI thread.

Should maybe the content assist be delegated to a worker thread? I think the JDT may do something like that. I remember seeing dedicated timeout messages on rare occasions, when the content assist wasn't responsive enough.
Comment 4 Oliver L CLA 2011-12-15 04:22:36 EST
Ok, therefore disabling "Mark occurences" again should work as workaround, right? Feels like a déjà vu ;-)
Comment 5 Knut Wannheden CLA 2011-12-15 04:36:14 EST
(In reply to comment #4)
> Ok, therefore disabling "Mark occurences" again should work as workaround,
> right? Feels like a déjà vu ;-)

Yes, that should do it.

It's a lock order inversion problem. I think the DefaultOccurrenceComputer should have its own implementation of EditorResourceAccess overriding getOpenDocument() to return the reference to the document it already has. Then the UI thread would not be required.

But then again this is probably a general problem of EditorResourceAccess. Of course it only affects clients which don't already run in the UI thread. So I suppose the EditorResourceAccess#getOpenDocument() implementation should additionally assert that it is executing in the UI thread.
Comment 6 Jan Koehnlein CLA 2011-12-19 09:20:03 EST
Created attachment 208553 [details]
Avoid using accessing the UI thread in DefaultOccurrenceComputer

Here's a patch to resolve this issue:

As the DefaultOccurrenceComputer already locks the document, it should be safe to use a SimpleLocalResourceAccess, i.e. use the current document's resource set to resolve local cross references. So there is no need to access the UI thread while calculating the annotations.

Knut, what do you think?
Comment 7 Knut Wannheden CLA 2011-12-19 11:23:00 EST
Hi Jan

Yes, you're right, that would solve this particular problem.

But I find it somewhat discomforting and inelegant that deadlocks are still possible when using the EditorResourceAccess directly or indirectly (e.g. through the reference finder API) inside an IXtextDocument transaction and when not executing in the UI thread. I think it would be good if we could avoid this situation completely or detect it and raise an exception when it occurs. Any thoughts on this?
Comment 8 Jan Koehnlein CLA 2011-12-21 08:14:56 EST
Introduced a OpenDocumentTracker for the EditorResourceAccess that doesn't need a document lock and is populated by means of Part/PageListeners.

Also added the proposed fix in the occurrence computer.
Comment 9 Stephan Herrmann CLA 2012-02-06 13:21:34 EST
Should I be worried by (repeatedly) seeing this bug in Xtext 2.2.1, while 
the fix is supposed to be in 2.2.0 M5?

But then, 2.2.1 is actually 2.2.1.v201112130541 which seems to pre-date 
the fix in this bug, hm? :-/
Comment 10 Sven Efftinge CLA 2012-02-06 13:25:22 EST
We use the version tag to determine in which version the bug was found. The fix is in M5 of juno (2.3.0 stream).
Comment 11 Stephan Herrmann CLA 2012-02-06 16:39:02 EST
(In reply to comment #10)
> We use the version tag to determine in which version the bug was found.

Thanks, of course, I should know. Sorry.

> The fix is in M5 of juno (2.3.0 stream).

The confusing part is that "M5" is unqualified. Will this be the only M5 in the project's life time? ;-P

For reference: in platform projects this would be "2.3 M5".
Comment 12 Sven Efftinge CLA 2012-02-07 01:35:39 EST
The qualifier is the juno flag. 
However, this is only sufficient as long as we only have releases aligned with the train, which no longer do.
Comment 13 Karsten Thoms CLA 2017-09-19 17:41:37 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 14 Karsten Thoms CLA 2017-09-19 17:52:45 EDT
Closing all bugs that were set to RESOLVED before Neon.0