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

Bug 320182

Summary: Deadlock in JobManagerAdapter during shutdown
Product: [RT] RAP Reporter: Benjamin Muskalla <b.muskalla>
Component: WorkbenchAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: digga1404, phil.xue, ruediger.herrmann, wolfgang.pedot
Version: 1.3   
Target Milestone: 1.5 M4   
Hardware: All   
OS: All   
Whiteboard: sr142
Attachments:
Description Flags
deadlock thread dump
none
Proposed fix for HEAD
none
Adopted patch (attachment 205970) for 14_Maintenance branch rsternberg: review+

Description Benjamin Muskalla CLA 2010-07-17 17:58:04 EDT
Deadlock occurs during workbench shutdown as JobManager and Device are aquiring and waiting for deviceLock and JobManager#lock.

Thread [Worker-0] (Suspended)	
	owns: Object  (id=133)	
	waiting for: Object  (id=132)	
	Display(Device).isDisposed() line: 300	
	JobManagerAdapter.done(IJobChangeEvent) line: 119	
	JobListeners$3.notify(IJobChangeListener, IJobChangeEvent) line: 39	
	JobListeners.doNotify(JobListeners$IListenerDoit, IJobChangeEvent) line: 96	
	JobListeners.done(Job, IStatus, boolean) line: 152	
	JobManager.endJob(InternalJob, IStatus, boolean) line: 646	
	JobManager.startJob() line: 1483	
	WorkerPool.startJob(Worker) line: 218	
	Worker.run() line: 50	



Daemon Thread [UIThread [1m4l2ysrx0k1vz52o0aige08m]] (Suspended)	
	owns: Object  (id=132)	
	owns: UIThread  (id=32)	
	waiting for: Object  (id=133)	
	JobManager.select(Object, int) line: 1158	
	JobManager.select(Object) line: 1148	
	JobManager.cancel(Object) line: 333	
	QueryResultPane(AbstractEditorPane).dispose() line: 162	
	MultiPaneEditor$8.run() line: 637	
	SafeRunner.run(ISafeRunnable) line: 42	
	HeapEditor(MultiPaneEditor).disposePart(IWorkbenchPart) line: 633	
	HeapEditor.disposePart(IWorkbenchPart) line: 378	
	HeapEditor(MultiPaneEditor).dispose() line: 433	
	HeapEditor.dispose() line: 223	
	EditorReference(WorkbenchPartReference).doDisposePart() line: 730	
	EditorReference.doDisposePart() line: 301	
	EditorReference(WorkbenchPartReference).dispose() line: 681	
	WorkbenchPage.disposePart(WorkbenchPartReference) line: 1586	
	WorkbenchPage.handleDeferredEvents() line: 1344	
	WorkbenchPage.deferUpdates(boolean) line: 1328	
	WorkbenchPage.closeEditors(IEditorReference[], boolean) line: 1302	
	WorkbenchPage.closeAllEditors(boolean) line: 1125	
	WorkbenchPage.dispose() line: 1636	
	WorkbenchWindow.closeAllPages() line: 810	
	WorkbenchWindow.hardClose() line: 1635	
	WorkbenchWindow.busyClose() line: 683	
	WorkbenchWindow.access$0(WorkbenchWindow) line: 659	
	WorkbenchWindow$2.run() line: 775	
	BusyIndicator.showWhile(Display, Runnable) line: 66	
	WorkbenchWindow.close() line: 773	
	WindowManager.close() line: 109	
	Workbench$13.run() line: 861	
	SafeRunner.run(ISafeRunnable) line: 42	
	Workbench.busyClose(boolean) line: 858	
	Workbench.access$12(Workbench, boolean) line: 781	
	Workbench$21.run() line: 1047	
	BusyIndicator.showWhile(Display, Runnable) line: 66	
	Workbench.close(int, boolean) line: 1045	
	Workbench.close() line: 1007	
	Workbench$ShutdownHandler.handleEvent(Event) line: 131	
	Display.sendDisposeEvent() line: 714	
	Display.release() line: 693	
	Display(Device).dispose() line: 282	
	Application.start(IApplicationContext) line: 33	
	EntrypointApplicationWrapper.createUI() line: 27	
	EntryPointManager.createUI(String) line: 92	
	RWTLifeCycle.createUI() line: 245	
	RWTLifeCycle$UIThreadController.run() line: 114	
	UIThread(Thread).run() line: 619 [local variables unavailable]	
	UIThread.run() line: 102	

Will try to come up with a simple project to reproduce.
Comment 1 Phil Xue CLA 2010-11-03 22:13:07 EDT
I ran into the same deadlock today, thread dump is attached.
Comment 2 Phil Xue CLA 2010-11-03 22:14:03 EDT
Created attachment 182346 [details]
deadlock thread dump
Comment 3 Rüdiger Herrmann CLA 2011-10-26 05:05:56 EDT
Created attachment 205970 [details]
Proposed fix for HEAD

We are still not able to reproduce this dead lock. However, in JobManagerAdapter#done(), there is a code passage that attempts to acquire a Display-lock while holding a JobManager-lock.
The patch moves the acquisition of the Display-lock outside the block that is guarded by the JobManager-lock.
If this patch solves the deadlock please report here.
Comment 4 Julien Saulou CLA 2011-11-14 11:05:17 EST
Just to let you know that we encountered the same deadlock and that the patch supplied by Herrmann did fix the problem.
We don't have much more information as to why this happens but if you have questions, don't hesitate to ask.
Comment 5 Rüdiger Herrmann CLA 2011-11-14 16:42:24 EST
With some more testing and the feedback from comment #4 I am confident that the patch from attachment 205970 [details] solves this bug and doesn't introduce other issues.
Applied to CVS HEAD.
Comment 6 Rüdiger Herrmann CLA 2011-12-13 08:41:18 EST
*** Bug 366517 has been marked as a duplicate of this bug. ***
Comment 7 Ivan Furnadjiev CLA 2012-01-24 04:16:45 EST
Ruediger, does this patch fit (suitable) for the 1.4 maintenance branch?
Comment 8 Wolfgang Pedot CLA 2012-01-24 04:38:25 EST
We have been using this patch in our application (1.4.0) for about a month (~6000 Sessions since then) and have not noticed any sideeffects other than not having that deadlock any more.
Comment 9 Rüdiger Herrmann CLA 2012-01-24 05:51:38 EST
(In reply to comment #7)
> Ruediger, does this patch fit (suitable) for the 1.4 maintenance branch?
If the patch itself applies without conflicts, it is safe to commit it to 1.4
Comment 10 Ivan Furnadjiev CLA 2012-01-25 02:30:27 EST
Created attachment 210031 [details]
Adopted patch (attachment 205970 [details]) for 14_Maintenance branch
Comment 11 Ivan Furnadjiev CLA 2012-01-25 06:33:20 EST
Applied patch to v14_Maintenance branch.