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

Bug 96045

Summary: The new progress monitor is running the event loop during class loading
Product: [Eclipse Project] Platform Reporter: Stefan Xenos <sxenos>
Component: UIAssignee: Boris Bokowski <bokowski>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: michaelvanmeekeren
Version: 3.1   
Target Milestone: 3.1 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 95667    
Bug Blocks:    

Description Stefan Xenos CLA 2005-05-19 20:11:37 EDT
I got the following exception in my log while launching my target. This seems to
be due to line 1423 of workbench.java, which is reading events from the event loop.

Whenever code runs events from the event loop, it gives any background thread
permission to run *syncExecs. Since this code is running in a bundle listener,
it can get triggered by classloading. This makes it virtually impossible to lock
the UI thread during startup and can cause all sorts of concurrency issues
(stack traces will differ wildly since anything that posts a *syncExec can
interfere with anything that loads a class in the UI thread).

Long story short: bundle listeners aren't allowed to call Display.readAndDispatch().

SWT Exception on startup

Thread [main] (Suspended (exception IllegalArgumentException))
	SWT.error(int, Throwable, String) line: 2924
	SWT.error(int, Throwable) line: 2863
	SWT.error(int) line: 2834
	Image.internal_new_GC(GCData) line: 1836
	GC.<init>(Drawable, int) line: 127
	GC.<init>(Drawable) line: 94
	AnnotationRulerColumn.doubleBufferPaint(GC) line: 499
	AnnotationRulerColumn.redraw() line: 802
	AnnotationRulerColumn$6.run() line: 789
	RunnableLock.run() line: 35
	UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 118
	Display.runAsyncMessages(boolean) line: 2898
	Display.readAndDispatch() line: 2557
	Workbench$16.bundleChanged(BundleEvent) line: 1423
	BundleContextImpl.dispatchEvent(Object, Object, int, Object) line: 1205
	EventManager.dispatchEvent(EventListeners$ListElement[], EventDispatcher, int,
Object) line: 188
	ListenerQueue.dispatchEventSynchronous(int, Object) line: 141
	Framework.publishBundleEventPrivileged(BundleEvent) line: 1451
	Framework.publishBundleEvent(int, Bundle) line: 1402
	BundleHost.startWorker(boolean) line: 330
	BundleHost(AbstractBundle).start() line: 266
	EclipseClassLoader.findLocalClass(String) line: 112
	BundleLoader.findLocalClass(String) line: 337
	BundleLoader.findClass(String, boolean) line: 389
	BundleLoader.findClass(String) line: 350
	EclipseClassLoader(AbstractClassLoader).loadClass(String, boolean) line: 74
	EclipseClassLoader(ClassLoader).loadClass(String) line: 235
	BundleLoader.loadClass(String) line: 275
	BundleHost.loadClass(String, boolean) line: 227
	BundleHost(AbstractBundle).loadClass(String) line: 1259
	ConfigurationElement.createExecutableExtension(Bundle, String, Object,
ConfigurationElement, String) line: 152
	ConfigurationElement.createExecutableExtension(String, String, Object,
ConfigurationElement, String) line: 142
	ConfigurationElement.createExecutableExtension(String) line: 129
	ConfigurationElementHandle.createExecutableExtension(String) line: 48
	ContributedProcessorDescriptor.getProcessor(ICompilationUnit) line: 91
	JavaCorrectionProcessor$SafeHasCorrections.safeRun(ContributedProcessorDescriptor)
line: 381
	JavaCorrectionProcessor$SafeHasCorrections(JavaCorrectionProcessor$SafeCorrectionProcessorAccess).run()
line: 275
	InternalPlatform.run(ISafeRunnable) line: 1031
	Platform.run(ISafeRunnable) line: 775
	JavaCorrectionProcessor$SafeHasCorrections(JavaCorrectionProcessor$SafeCorrectionProcessorAccess).process(ContributedProcessorDescriptor)
line: 271
	JavaCorrectionProcessor.hasCorrections(ICompilationUnit, int) line: 99
	JavaCorrectionProcessor.hasCorrections(Annotation) line: 119
	JavaAnnotationImageProvider.showQuickFix(IJavaAnnotation) line: 88
	JavaAnnotationImageProvider.getImageType(IJavaAnnotation) line: 114
	JavaAnnotationImageProvider.getManagedImage(Annotation) line: 64
	DefaultMarkerAnnotationAccess.getImage(Annotation, AnnotationPreference,
String) line: 329
	DefaultMarkerAnnotationAccess.paint(Annotation, GC, Canvas, Rectangle) line: 234
	AnnotationRulerColumn.doPaint1(GC) line: 772
	AnnotationRulerColumn.doubleBufferPaint(GC) line: 506
	AnnotationRulerColumn.redraw() line: 802
	AnnotationRulerColumn$6.run() line: 789
	RunnableLock.run() line: 35
	UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 118
	Display.runAsyncMessages(boolean) line: 2898
	Display.readAndDispatch() line: 2557
	Workbench$16.bundleChanged(BundleEvent) line: 1423
	BundleContextImpl.dispatchEvent(Object, Object, int, Object) line: 1205
	EventManager.dispatchEvent(EventListeners$ListElement[], EventDispatcher, int,
Object) line: 188
	ListenerQueue.dispatchEventSynchronous(int, Object) line: 141
	Framework.publishBundleEventPrivileged(BundleEvent) line: 1451
	Framework.publishBundleEvent(int, Bundle) line: 1402
	BundleHost.startWorker(boolean) line: 330
	BundleHost(AbstractBundle).start() line: 266
	EclipseClassLoader.findLocalClass(String) line: 112
	BundleLoader.findLocalClass(String) line: 337
	SingleSourcePackage.loadClass(String) line: 37
	BundleLoader.findClass(String, boolean) line: 386
	BundleLoader.findClass(String) line: 350
	EclipseClassLoader(AbstractClassLoader).loadClass(String, boolean) line: 74
	EclipseClassLoader(ClassLoader).loadClass(String) line: 235
	EclipseClassLoader(ClassLoader).loadClassInternal(String) line: 302
	ClassLoader.defineClass0(String, byte[], int, int, ProtectionDomain) line: not
available [native method]
	EclipseClassLoader(ClassLoader).defineClass(String, byte[], int, int,
ProtectionDomain) line: 537
	EclipseClassLoader(DefaultClassLoader).defineClass(String, byte[], int, int,
DefaultClassLoader$ClasspathEntry) line: 321
	EclipseClassLoader.defineClass(String, byte[], int, int,
DefaultClassLoader$ClasspathEntry) line: 223
	EclipseClassLoader(DefaultClassLoader).findClassImpl(String,
DefaultClassLoader$ClasspathEntry) line: 304
	EclipseClassLoader(DefaultClassLoader).findClass(String) line: 196
	EclipseClassLoader(AbstractClassLoader).findLocalClass(String) line: 179
	EclipseClassLoader.basicFindLocalClass(String) line: 137
	EclipseClassLoader.findLocalClass(String) line: 78
	BundleLoader.findLocalClass(String) line: 337
	BundleLoader.findClass(String, boolean) line: 389
	BundleLoader.findClass(String) line: 350
	EclipseClassLoader(AbstractClassLoader).loadClass(String, boolean) line: 74
	EclipseClassLoader(ClassLoader).loadClass(String) line: 235
	BundleLoader.loadClass(String) line: 275
	BundleHost.loadClass(String, boolean) line: 227
	BundleHost(AbstractBundle).loadBundleActivator() line: 144
	BundleContextImpl.start() line: 965
	BundleHost.startWorker(boolean) line: 321
	BundleHost(AbstractBundle).start() line: 266
	EclipseClassLoader.findLocalClass(String) line: 112
	BundleLoader.findLocalClass(String) line: 337
	BundleLoader.findClass(String, boolean) line: 389
	BundleLoader.findClass(String) line: 350
	EclipseClassLoader(AbstractClassLoader).loadClass(String, boolean) line: 74
	EclipseClassLoader(ClassLoader).loadClass(String) line: 235
	BundleLoader.loadClass(String) line: 275
	BundleHost.loadClass(String, boolean) line: 227
	BundleHost(AbstractBundle).loadClass(String) line: 1259
	ConfigurationElement.createExecutableExtension(Bundle, String, Object,
ConfigurationElement, String) line: 152
	ConfigurationElement.createExecutableExtension(String, String, Object,
ConfigurationElement, String) line: 142
	ConfigurationElement.createExecutableExtension(String) line: 129
	ConfigurationElementHandle.createExecutableExtension(String) line: 48
	WorkbenchPlugin$1.run() line: 240
	BusyIndicator.showWhile(Display, Runnable) line: 69
	WorkbenchPlugin.createExtension(IConfigurationElement, String) line: 236
	WWinPluginPulldown(PluginAction).createDelegate() line: 118
	WWinPluginPulldown.getPulldownDelegate() line: 203
	WWinPluginPulldown$MenuProxy.getMenu(Menu) line: 151
	PluginActionContributionItem(ActionContributionItem).fill(Menu, int) line: 259
	ActionSetContributionItem(SubContributionItem).fill(Menu, int) line: 65
	MenuManager.update(boolean, boolean) line: 627
	MenuManager.update(boolean) line: 549
	MenuManager.fill(Menu, int) line: 232
	ActionSetContributionItem(SubContributionItem).fill(Menu, int) line: 65
	MenuManager.update(boolean, boolean) line: 627
	MenuManager.updateAll(boolean) line: 721
	WorkbenchWindow.updateActionBars() line: 2472
	WorkbenchWindow.updateActionSets() line: 2542
	WorkbenchWindow$5.run() line: 2362
	BusyIndicator.showWhile(Display, Runnable) line: 69
	WorkbenchWindow.setActivePage(IWorkbenchPage) line: 2325
	WorkbenchWindow.restoreState(IMemento, IPerspectiveDescriptor) line: 1848
	Workbench$17.run(IProgressMonitor) line: 1493
	ModalContext.runInCurrentThread(IRunnableWithProgress, IProgressMonitor) line: 346
	ModalContext.run(IRunnableWithProgress, boolean, IProgressMonitor, Display)
line: 291
	ProgressMonitorDialog.run(boolean, boolean, IRunnableWithProgress) line: 447
	Workbench.restoreState(IMemento) line: 1434
	Workbench.access$9(Workbench, IMemento) line: 1391
	Workbench$14.run() line: 1274
	InternalPlatform.run(ISafeRunnable) line: 1031
	Platform.run(ISafeRunnable) line: 775
	Workbench.restoreState() line: 1218
	WorkbenchConfigurer.restoreState() line: 173
	IDEWorkbenchAdvisor(WorkbenchAdvisor).openWindows() line: 700
	Workbench.init(Display) line: 995
	Workbench.runUI() line: 1649
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 329
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 143
	IDEApplication.run(Object) line: 103
	PlatformActivator$1.run(Object) line: 226
	EclipseStarter.run(Object) line: 372
	EclipseStarter.run(String[], Runnable) line: 161
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available
[native method]
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
	Method.invoke(Object, Object[]) line: 324
	Main.invokeFramework(String[], URL[]) line: 330
	Main.basicRun(String[]) line: 274
	Main.run(String[]) line: 977
	Main.main(String[]) line: 952
Comment 1 Boris Bokowski CLA 2005-05-20 12:52:48 EDT
We have changed the BundleListener to call Display#update instead of spinning
the event loop.
Comment 2 Boris Bokowski CLA 2005-05-26 10:44:03 EDT
Marking as fixed since Display#update works better than spinning the event 
loop.
Comment 3 Boris Bokowski CLA 2005-05-27 13:33:24 EDT
Verified in I20050527-0900.