| Summary: | dead lock when organizing imports | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Rafael Chaves <eclipse> |
| Component: | Resources | Assignee: | John Arthorne <john.arthorne> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | pascal, Tod_Creasey |
| Version: | 3.0 | ||
| Target Milestone: | 3.0 M3 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 41810 | ||
Actually, I could reproduce it even without cancelling the operation. Provided a progress dialog comes up (I believe it depends on the project having more than one source file), Eclipse will freeze. This is the same bug the VCM team is getting. To reproduce:
Create an IWorkspaceRunnable that does a syncExec that tries to modify the
workspace. Here is a sample program:
final IWorkspace ws = ResourcesPlugin.getWorkspace();
ws.run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) {
window.getShell().getDisplay().syncExec(new Runnable() {
public void run() {
System.out.println("Inside syncExec");
try {
ws.run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) {
}
}, null);
} catch (CoreException e) {
}
}
});
}
}, null);
The question is: is this a valid pattern? Since they are modifying the workspace from within a syncExec, then it is absolutely guaranteed that they are running a long running task in the UI thread. This means no painting or UI response until the operation completes. The old workspace lock allowed this to happen, since it had special handling in the UI to allow the nested operation to continue without re-acquiring the lock. This is much more difficult when using job rules as the locking mechanism: we don't know exactly which thread is blocking the nested operation from running, since rules, unlike locks, don't have a single thread that is identifiable as the owner. The solution: either we work some magic in core to allow this to proceed, or we educate clients that acquiring a lock, and then syncExecing and acquiring another lock, is just a bad idea. Fixed bogus summary... Added me so that I can apply the patch to the UI Fix released for M3 build. |
i20030820 This seems to be always reproducible (regardless the VM in use): when doing a massive organize imports operation on a project, if you try to cancel it, a dead lock will occur. Steps: 1 - select a Java project in the Project Explorer 2 - press Ctrl-Shift-O (Organize imports) 3 - when the progress dialog appears, press the cancel button. Eclipse will freeze (no CPU activity). Stack trace dump: Stack Traces of Threads: ThreadName=main(00034F44) Status=Waiting Monitor=01805B38 (Object monitor for org/eclipse/core/internal/jobs/ImplicitJobs $ThreadJob @ 013840F0) Count=0 Owner=(00000000) In java/lang/Object.wait(JI)V In java/lang/Object.wait()V In org/eclipse/core/internal/jobs/ImplicitJobs$ThreadJob.joinRun()V In org/eclipse/core/internal/jobs/ImplicitJobs.begin(Lorg/eclipse/core/r untime/jobs/ISchedulingRule;)V In org/eclipse/core/internal/jobs/JobManager.beginRule(Lorg/eclipse/core /runtime/jobs/ISchedulingRule;)V In org/eclipse/core/internal/resources/WorkManager.checkIn(Lorg/eclipse/ core/runtime/jobs/ISchedulingRule;)V In org/eclipse/core/internal/resources/Workspace.prepareOperation(Lorg/e clipse/core/runtime/jobs/ISchedulingRule;)V In org/eclipse/core/internal/resources/Workspace.run(Lorg/eclipse/core/r esources/IWorkspaceRunnable;Lorg/eclipse/core/runtime/jobs/ISchedulingRule;Lorg/ eclipse/core/runtime/IProgressMonitor;)V In org/eclipse/core/internal/resources/Workspace.run(Lorg/eclipse/core/r esources/IWorkspaceRunnable;Lorg/eclipse/core/runtime/IProgressMonitor;)V In org/eclipse/jdt/internal/corext/textmanipulation/TextBufferFactory.co mmitChanges(Lorg/eclipse/jdt/internal/corext/textmanipulation/TextBuffer;ZLorg/e clipse/core/runtime/IProgressMonitor;)V In org/eclipse/jdt/internal/corext/textmanipulation/TextBuffer.commitCha nges(Lorg/eclipse/jdt/internal/corext/textmanipulation/TextBuffer;ZLorg/eclipse/ core/runtime/IProgressMonitor;)V In org/eclipse/jdt/internal/corext/codemanipulation/ImportsStructure.cre ate(ZLorg/eclipse/core/runtime/IProgressMonitor;)V In org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOpera tion.run(Lorg/eclipse/core/runtime/IProgressMonitor;)V In org/eclipse/jdt/ui/actions/OrganizeImportsAction$3.run()V In org/eclipse/ui/internal/UILockListener.doPendingWork()V In org/eclipse/ui/internal/UISynchronizer$1.run()V In org/eclipse/swt/widgets/RunnableLock.run()V In org/eclipse/swt/widgets/Synchronizer.runAsyncMessages()Z In org/eclipse/swt/widgets/Display.runAsyncMessages()Z In org/eclipse/swt/widgets/Display.readAndDispatch()Z In org/eclipse/jface/operation/ModalContext$ModalContextThread.block()V In org/eclipse/jface/operation/ModalContext.run(Lorg/eclipse/jface/opera tion/IRunnableWithProgress;ZLorg/eclipse/core/runtime/IProgressMonitor;Lorg/ecli pse/swt/widgets/Display;)V In org/eclipse/jface/dialogs/ProgressMonitorDialog.run(ZZLorg/eclipse/jf ace/operation/IRunnableWithProgress;)V In org/eclipse/jdt/ui/actions/OrganizeImportsAction.runOnMultiple([Lorg/ eclipse/jdt/core/ICompilationUnit;)V In org/eclipse/jdt/ui/actions/OrganizeImportsAction.run(Lorg/eclipse/jfa ce/viewers/IStructuredSelection;)V In org/eclipse/jdt/ui/actions/SelectionDispatchAction.dispatchRun(Lorg/e clipse/jface/viewers/ISelection;)V In org/eclipse/jdt/ui/actions/SelectionDispatchAction.run()V In org/eclipse/jface/action/Action.runWithEvent(Lorg/eclipse/swt/widgets /Event;)V In org/eclipse/ui/actions/RetargetAction.runWithEvent(Lorg/eclipse/swt/w idgets/Event;)V In org/eclipse/ui/internal/WWinPluginAction.runWithEvent(Lorg/eclipse/sw t/widgets/Event;)V In org/eclipse/jface/action/ActionContributionItem.handleWidgetSelection (Lorg/eclipse/swt/widgets/Event;Z)V In org/eclipse/jface/action/ActionContributionItem.access$4(Lorg/eclipse /jface/action/ActionContributionItem;Lorg/eclipse/swt/widgets/Event;Z)V In org/eclipse/jface/action/ActionContributionItem$6.handleEvent(Lorg/ec lipse/swt/widgets/Event;)V In org/eclipse/swt/widgets/EventTable.sendEvent(Lorg/eclipse/swt/widgets /Event;)V In org/eclipse/swt/widgets/Widget.sendEvent(Lorg/eclipse/swt/widgets/Eve nt;)V In org/eclipse/swt/widgets/Display.runDeferredEvents()Z In org/eclipse/swt/widgets/Display.readAndDispatch()Z In org/eclipse/ui/internal/Workbench.runEventLoop(Lorg/eclipse/jface/win dow/Window$IExceptionHandler;)V In org/eclipse/ui/internal/Workbench.run(Ljava/lang/Object;)Ljava/lang/O bject; In org/eclipse/core/internal/boot/InternalBootLoader.run(Ljava/lang/Stri ng;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/Runnable;)Ljava /lang/Object; In org/eclipse/core/boot/BootLoader.run(Ljava/lang/String;Ljava/net/URL; Ljava/lang/String;[Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Object; In java/lang/reflect/AccessibleObject.invokeL(Ljava/lang/Object;[Ljava/l ang/Object;)Ljava/lang/Object; In java/lang/reflect/Method.invoke(Ljava/lang/Object;[Ljava/lang/Object; )Ljava/lang/Object; In org/eclipse/core/launcher/Main.basicRun([Ljava/lang/String;)Ljava/lan g/Object; In org/eclipse/core/launcher/Main.run([Ljava/lang/String;)Ljava/lang/Obj ect; In org/eclipse/core/launcher/Main.main([Ljava/lang/String;)V ThreadName=Gc Thread(00035094) Status=Waiting Monitor=00034550 (System monitor) Count=0 Owner=(00000000) ThreadName=Finalizer thread(000350E8) Status=Waiting Monitor=00034B50 (System monitor) Count=0 Owner=(00000000) ThreadName=Java indexing(0003513C) Status=Waiting Monitor=01805238 (Object monitor for org/eclipse/jdt/internal/core/search/indexi ng/IndexManager @ 00FDF5EC) Count=0 Owner=(00000000) In java/lang/Object.wait(JI)V In java/lang/Object.wait()V In org/eclipse/jdt/internal/core/search/processing/JobManager.run()V In java/lang/Thread.run()V ThreadName=org.eclipse.jdt.internal.ui.text.JavaReconciler(00035238) Status=Waiting Monitor=01805568 (System monitor) Count=0 Owner=(00000000) In java/lang/Object.wait(JI)V In java/lang/Object.wait(J)V In org/eclipse/jface/text/reconciler/AbstractReconciler$BackgroundThread .run()V ThreadName=org.eclipse.jdt.internal.ui.text.JavaReconciler(000352E0) Status=Waiting Monitor=01805958 (System monitor) Count=0 Owner=(00000000) In java/lang/Object.wait(JI)V In java/lang/Object.wait(J)V In org/eclipse/jface/text/reconciler/AbstractReconciler$BackgroundThread .run()V ThreadName=org.eclipse.jdt.internal.ui.text.JavaReconciler(0003528C) Status=Waiting Monitor=01805658 (System monitor) Count=0 Owner=(00000000) In java/lang/Object.wait(JI)V In java/lang/Object.wait(J)V In org/eclipse/jface/text/reconciler/AbstractReconciler$BackgroundThread .run()V ThreadName=org.eclipse.jdt.internal.ui.text.JavaReconciler(000355D4) Status=Waiting Monitor=01805AA8 (System monitor) Count=0 Owner=(00000000) In java/lang/Object.wait(JI)V In java/lang/Object.wait(J)V In org/eclipse/jface/text/reconciler/AbstractReconciler$BackgroundThread .run()V ThreadName=Worker-20(00035430) Status=Waiting Monitor=018054A8 (Object monitor for org/eclipse/core/internal/jobs/WorkerPool @ 009280D8) Count=0 Owner=(00000000) In java/lang/Object.wait(JI)V In java/lang/Object.wait(J)V In org/eclipse/core/internal/jobs/WorkerPool.sleep(J)V In org/eclipse/core/internal/jobs/WorkerPool.startJob()Lorg/eclipse/core /runtime/jobs/Job; In org/eclipse/core/internal/jobs/Worker.run()V ThreadName=ModalContext(00035388) Status=Waiting Monitor=01805BF8 (Object monitor for org/eclipse/ui/internal/Semaphore @ 012C01E 4) Count=0 Owner=(00000000) In java/lang/Object.wait(JI)V In java/lang/Object.wait(J)V In org/eclipse/ui/internal/Semaphore.acquire(J)Z In org/eclipse/ui/internal/UISynchronizer.syncExec(Ljava/lang/Runnable;) V In org/eclipse/swt/widgets/Display.syncExec(Ljava/lang/Runnable;)V In org/eclipse/jdt/ui/actions/OrganizeImportsAction.runInSync(Lorg/eclip se/jdt/internal/corext/codemanipulation/OrganizeImportsOperation;Ljava/lang/Stri ng;Lorg/eclipse/core/runtime/MultiStatus;Lorg/eclipse/core/runtime/IProgressMoni tor;)V In org/eclipse/jdt/ui/actions/OrganizeImportsAction.doRunOnMultiple([Lor g/eclipse/jdt/core/ICompilationUnit;Lorg/eclipse/core/runtime/MultiStatus;Lorg/e clipse/core/runtime/IProgressMonitor;)V In org/eclipse/jdt/ui/actions/OrganizeImportsAction.access$0(Lorg/eclips e/jdt/ui/actions/OrganizeImportsAction;[Lorg/eclipse/jdt/core/ICompilationUnit;L org/eclipse/core/runtime/MultiStatus;Lorg/eclipse/core/runtime/IProgressMonitor; )V In org/eclipse/jdt/ui/actions/OrganizeImportsAction$1.run(Lorg/eclipse/c ore/runtime/IProgressMonitor;)V In org/eclipse/jdt/internal/core/BatchOperation.executeOperation()V In org/eclipse/jdt/internal/core/JavaModelOperation.execute()V In org/eclipse/jdt/internal/core/JavaModelOperation.run(Lorg/eclipse/cor e/runtime/IProgressMonitor;)V In org/eclipse/core/internal/resources/Workspace.run(Lorg/eclipse/core/r esources/IWorkspaceRunnable;Lorg/eclipse/core/runtime/jobs/ISchedulingRule;Lorg/ eclipse/core/runtime/IProgressMonitor;)V In org/eclipse/core/internal/resources/Workspace.run(Lorg/eclipse/core/r esources/IWorkspaceRunnable;Lorg/eclipse/core/runtime/IProgressMonitor;)V In org/eclipse/jdt/core/JavaCore.run(Lorg/eclipse/core/resources/IWorksp aceRunnable;Lorg/eclipse/core/runtime/IProgressMonitor;)V In org/eclipse/jdt/internal/ui/actions/WorkbenchRunnableAdapter.run(Lorg /eclipse/core/runtime/IProgressMonitor;)V In org/eclipse/jface/operation/ModalContext$ModalContextThread.run()V