Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 168028 - Deadlock on close resource action
Summary: Deadlock on close resource action
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M5   Edit
Assignee: PDE-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 166176 170343 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-12-14 05:29 EST by Benno Baumgartner CLA
Modified: 2007-01-29 02:01 EST (History)
4 users (show)

See Also:


Attachments
Thread Dump (20.40 KB, text/plain)
2006-12-14 05:30 EST, Benno Baumgartner CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Benno Baumgartner CLA 2006-12-14 05:29:45 EST
I20061212-0010

I did select multiple projects (around 10 projects) in the package explorer and then 'Close Project'. Result looks like a deadlock (see attachment for full thread dump):

"Worker-16" prio=6 tid=0x047da950 nid=0x768 in Object.wait() [0x0781f000..0x0781fc68]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x19c824b8> (a org.eclipse.core.internal.jobs.Semaphore)
        at org.eclipse.core.internal.jobs.Semaphore.acquire(Semaphore.java:38)
        - locked <0x19c824b8> (a org.eclipse.core.internal.jobs.Semaphore)
        at org.eclipse.core.internal.jobs.OrderedLock.doAcquire(OrderedLock.java:169)
        at ...
...
org.eclipse.pde.internal.core.PluginModelManager$1.modelsChanged(PluginModelManager.java:63)
        at org.eclipse.pde.internal.core.WorkspaceModelManager.fireModelProviderEvent(WorkspaceModelManager.java:755)
        - locked <0x161fb060> (a org.eclipse.pde.internal.core.WorkspaceModelManager)
        at org.eclipse.pde.internal.core.WorkspaceModelManager.processModelChanges(WorkspaceModelManager.java:749)
        at org.eclipse.pde.internal.core.WorkspaceModelManager.resourceChanged(WorkspaceModelManager.java:466)
...
...
org.eclipse.core.internal.resources.Workspace.broadcastEvent(Workspace.java:251)
        at org.eclipse.core.internal.resources.Project.close(Project.java:138)
        at org.eclipse.ui.actions.CloseResourceAction.invokeOperation(CloseResourceAction.java:184)
        at org.eclipse.ui.actions.WorkspaceAction.execute(WorkspaceAction.java:141)
        at org.eclipse.ui.actions.WorkspaceAction$1.runInWorkspace(WorkspaceAction.java:460)
        at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

and


"Worker-25" prio=6 tid=0x0428e138 nid=0xc00 waiting for monitor entry [0x07eef000..0x07eef9e8]
        at org.eclipse.pde.internal.core.WorkspaceModelManager.fireModelProviderEvent(WorkspaceModelManager.java:754)
        - waiting to lock <0x161fb060> (a org.eclipse.pde.internal.core.WorkspaceModelManager)
        at org.eclipse.pde.internal.core.WorkspaceModelManager.processModelChanges(WorkspaceModelManager.java:749)
        at ...
...
org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1752)
        at org.eclipse.core.internal.events.NotificationManager$NotifyJob.run(NotificationManager.java:39)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)


The semaphore seams not be released. 
Although I don't think that the problem is in Platform/UI I file it against you first because it was the close resource action.
Comment 1 Benno Baumgartner CLA 2006-12-14 05:30:33 EST
Created attachment 55656 [details]
Thread Dump
Comment 2 John Arthorne CLA 2006-12-15 14:57:32 EST
Yes, this is a deadlock between the workspace lock and the synchronized method WorkspaceModelManager.fireModelProviderEvent.  Worker-16 owns the lock on WorkspaceModelManager, and is trying to modify the workspace.  Worker-25 is in a POST_CHANGE resource change event, and is trying to acquire the WorkspaceModelManager lock.  The workspace lock is used to prevent other threads from modifying the workspace during a resource change event, so PDE needs to either:

1) Avoid changing the workspace while holding the WorkspaceModelManager lock.
2) Avoiding acquiring the WorkspaceModelManager lock during a POST_CHANGE resource change event.

Comment 3 Brian Bauman CLA 2006-12-27 10:04:42 EST
*** Bug 166176 has been marked as a duplicate of this bug. ***
Comment 4 Brian Bauman CLA 2007-01-12 13:54:02 EST
*** Bug 170343 has been marked as a duplicate of this bug. ***
Comment 5 Wassim Melhem CLA 2007-01-28 16:09:38 EST
Fixed in the new model code by not acquiring a lock when processing changes during a POST_CHANGE event.
Comment 6 Benjamin Pasero CLA 2007-01-29 02:01:29 EST
Happy to hear that! thanks