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

Bug 143198

Summary: SWTExceptions occurring when handling notifications from worker thread transactions
Product: [Modeling] GMF-Runtime Reporter: Neeraj Bhope <neerajbhope>
Component: GeneralAssignee: Steven R. Shaw <steveshaw>
Status: RESOLVED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: ahunter.eclipse, bnicolle, fplante, give.a.damus, mgoyal, schafe
Version: 1.0   
Target Milestone: 1.0   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on: 142803    
Bug Blocks:    
Attachments:
Description Flags
Alternate patch for this problem that is more general...
none
update patch none

Description Neeraj Bhope CLA 2006-05-23 08:54:45 EDT
This was reproducible on linux only.
The method tries to initialize the cursors which causes the non UI thread to wait for the UI thread. If the UI thread is already blocking on this thread it causes a deadlock.

Maneesh you could add a few more points here to describe this better and probably bump up the severity.
Comment 1 Steven R. Shaw CLA 2006-05-29 15:50:44 EDT
Is there a stack trace that could be added to give an indication where the deadlock is occurring?
Comment 2 Mohammed Mostafa CLA 2006-05-29 16:35:03 EDT
Steve; is not that defect similar to the threading issue you are working on 
Comment 3 Brent Nicolle CLA 2006-05-30 14:41:52 EDT
Why is this defect BP3, Major?
Submitter or Owner, please mark as BP1, Blocker (I cannot).
I cannot drag-and-drop onto a diagram without hanging workbench on Linux.
In my environment, it is 100% reproducible.

Comment 4 Neeraj Bhope CLA 2006-05-31 00:50:21 EDT
Bumped up the severity. Only owner can change the priority.
Comment 5 Steven R. Shaw CLA 2006-05-31 10:52:07 EDT
Requires fix from 142803 before this can be addressed...
Comment 6 Steven R. Shaw CLA 2006-05-31 13:06:50 EDT
- A new api is available for clients when responding to notification that come from a worker thread but they need access to SWT or resources reserved for the main thread.  @see EditPartUtil#synchronizeRunnableToMainThread.  Should be only be used when the client is sure that in the stack of execution SWT resources will be accessed directly.  Otherwise, this could incur a performance penalty when handling notifications.  Also, it may spawn the runnable asynchronously to the main thread which may break assumptions on ordering when the events are handled. 
- Instrumented this api in the installBendpointEditPolicy method.
Comment 7 Steven R. Shaw CLA 2006-06-14 15:52:56 EDT
Created attachment 44444 [details]
Alternate patch for this problem that is more general...

Some clients have indicated they are still encountering deadlock scenarios with progress meter forked operations.  Progress meter notifications are currently still handled on the worker thread which opens up clients to encountering SWTExceptions.  Since a recent transaction api fix was made which avoids deadlocks (146341), we can now synchronize notifications to the main thread irregardless of the progress meter use-case.  This is a more broad solution which avoids instrumenting specific parts of client code to synchronize to the main thread.

Waiting for client confirmation before reopening this defect...
Comment 8 Steven R. Shaw CLA 2006-06-15 08:47:22 EDT
Reopened to consider this new patch which is a more generic fix.
Comment 9 Steven R. Shaw CLA 2006-06-15 08:48:47 EDT
Targetting RC5. + renamed bugzilla to more reflective of the generic problem 
Comment 10 Steven R. Shaw CLA 2006-06-15 10:44:41 EDT
Downgrading to major until it is known whether another usecase exists where the generic fix would be necessary.  

Moving to 1.0.1 unless there are objections...
Comment 11 Steven R. Shaw CLA 2006-06-15 18:07:41 EDT
Confirmed with clients that original point fix is not sufficient (just exposes other problem areas) and that the generic fix is required to avoid SWTExceptions. 

Comment 12 Steven R. Shaw CLA 2006-06-16 10:32:21 EDT
Created attachment 44643 [details]
update patch 

Found another problem in DeferredLayoutCommand which calls refresh to update the shapes positions.  This causes can cause initialization of fonts.  Have to wrap this in a synchExec as well.  Patch has been updated accordingly...
Comment 13 Steven R. Shaw CLA 2006-06-16 13:49:47 EDT
Committed - For progress meter operations that fork a thread for execution, SWTExceptions were sometimes occurring when doing static initialization in client code.  Now DiagramEventBrokerThreadSafe will always synchronize notifications to the main thread using the privilegedRunnable irregardless of whether updates are disabled.
Comment 14 Richard Gronback CLA 2008-08-13 13:05:44 EDT
[target cleanup] 1.0 RC5 was the original target milestone for this bug
Comment 15 Eclipse Webmaster CLA 2010-07-19 12:28:44 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Runtime Diagram was the original product and component for this bug