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

Bug 398909

Summary: [DynamicGUI] UIExtensionTracker calling Display.syncExec() on disposed Display
Product: [Eclipse Project] Platform Reporter: Paul Webster <pwebster>
Component: UIAssignee: Paul Webster <pwebster>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bokowski, pwebster, tmhouser
Version: 3.6   
Target Milestone: 4.2.2+   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 321155    
Bug Blocks:    

Description Paul Webster CLA 2013-01-23 12:14:30 EST
This was not ported to the 4.x stream.

+++ This bug was initially created as a clone of Bug #321155 +++

Build Identifier: Eclipse SDK 3.6GA I20100608-0911

We have an RCP application that dynamically loads plugins with extensions.  The RCP application also dynamically unloads these plugins right before shutting down.

We get these exceptions in the <workspace>/.metadata/.log during shutdown:

!ENTRY org.eclipse.equinox.registry 4 2 2010-07-28 10:07:45.309
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.equinox.registry".
!STACK 0
org.eclipse.swt.SWTException: Device is disposed
	at org.eclipse.swt.SWT.error(SWT.java:4083)
	at org.eclipse.swt.SWT.error(SWT.java:3998)
	at org.eclipse.swt.SWT.error(SWT.java:3969)
	at org.eclipse.swt.widgets.Display.error(Display.java:1204)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4285)
	at org.eclipse.ui.internal.registry.UIExtensionTracker.applyRemove(UIExtensionTracker.java:42)
	at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.notify(ExtensionTracker.java:153)
	at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.doRemove(ExtensionTracker.java:179)
	at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.registryChanged(ExtensionTracker.java:119)
	at org.eclipse.core.internal.registry.ExtensionRegistry$2.run(ExtensionRegistry.java:921)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.registry.ExtensionRegistry.processChangeEvent(ExtensionRegistry.java:919)
	at org.eclipse.core.runtime.spi.RegistryStrategy.processChangeEvent(RegistryStrategy.java:260)
	at org.eclipse.core.internal.registry.osgi.ExtensionEventDispatcherJob.run(ExtensionEventDispatcherJob.java:50)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

!ENTRY org.eclipse.equinox.registry 4 0 2010-07-28 10:07:45.320
!MESSAGE Error notifying registry change listener.
!SUBENTRY 1 org.eclipse.equinox.registry 4 0 2010-07-28 10:07:45.320
!MESSAGE Error notifying registry change listener.
!STACK 0
org.eclipse.swt.SWTException: Device is disposed
	at org.eclipse.swt.SWT.error(SWT.java:4083)
	at org.eclipse.swt.SWT.error(SWT.java:3998)
	at org.eclipse.swt.SWT.error(SWT.java:3969)
	at org.eclipse.swt.widgets.Display.error(Display.java:1204)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4285)
	at org.eclipse.ui.internal.registry.UIExtensionTracker.applyRemove(UIExtensionTracker.java:42)
	at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.notify(ExtensionTracker.java:153)
	at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.doRemove(ExtensionTracker.java:179)
	at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.registryChanged(ExtensionTracker.java:119)
	at org.eclipse.core.internal.registry.ExtensionRegistry$2.run(ExtensionRegistry.java:921)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.registry.ExtensionRegistry.processChangeEvent(ExtensionRegistry.java:919)
	at org.eclipse.core.runtime.spi.RegistryStrategy.processChangeEvent(RegistryStrategy.java:260)
	at org.eclipse.core.internal.registry.osgi.ExtensionEventDispatcherJob.run(ExtensionEventDispatcherJob.java:50)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

This happens because there is a race condition between the main UI thread and the ExtensionEventDispatcherJob worker thread during shutdown such that registry change events are being handled after the display has been disposed during shutdown.  The registry change events that are fired are due to the dynamic unloading of plugins with extensions.

Either UIExtensionTracker should be written to handle the case when the display is disposed (i.e. handle the exception and quietly ignore it) or the extension registry should provide an API that the UI can call during shutdown that waits for these ExtensionEventDispatcherJob jobs to complete (e.g. calls IJobManager.join() on a job family for these jobs).

Reproducible: Always
Comment 2 Paul Webster CLA 2013-02-14 08:50:13 EST
I've released the fix to 4.3 and R4_2_1_maintenance_patches ... we need to wait to release it to 4.2.2+

PW