Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » SWT invalid thread access exception makes eclipse crash
SWT invalid thread access exception makes eclipse crash [message #904324] Tue, 28 August 2012 08:42 Go to next message
Maxime Jeanmart is currently offline Maxime JeanmartFriend
Messages: 35
Registered: November 2010
Member
Hi all,

I have an SWT Invalid Thread access exception at eclipse startup when I use the clean start option. This exception prevents eclipse to start because it happens during workbench initialization.

After some analysis, this exception is thrown because the WindowBuilder activator is called from a JDT builder job, which is not the main thread, and before the workbench is started. The activator (DesignerPlugin) calls Display.getDefault and makes the JDT builder thread the SWT UI thread. Unfortunately, the workbench requires the main thread to be the UI thread so eclipse crashes some time later.

To summarize, eclipse crashes because:
- The clean option makes eclipse startup slow
- The JDT builder calls the WindowBuilder activator before the workbench is initialized (or at least before the main thread is defined as UI thread)
- The WindowBuilder activator calls Display.getDefault from a Thread that is not the main thread
- The workbench requires the main thread to be the UI tread

Remark: I'm using indigo 3.7.1

Does anybody how to get around this issue? Our customer is used to start eclipse with clean option so it's a problem for him if we don't find a solution. Any idea is welcome.

Thanks,
Maxime

Here is the stack trace:
                at org.eclipse.swt.widgets.Display.getDefault(Display.java:1682)
                at org.eclipse.wb.internal.core.DesignerPlugin.addMouseWheelRedirector(DesignerPlugin.java:192)
                at org.eclipse.wb.internal.core.DesignerPlugin.start(DesignerPlugin.java:69)
                at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
                at java.security.AccessController.doPrivileged(Native Method)
                at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
                at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
                at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
                at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)
                at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440)
                at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:268)
                at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107)
                at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:462)
                at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
                at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:400)
                at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:476)
                at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
                at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
                at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
                at java.lang.ClassLoader.loadClass(Unknown Source)
                at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:345)
                at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229)
                at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1207)
                at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
                at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
                at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
                at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
                at org.eclipse.core.internal.content.ContentType.getDescriber(ContentType.java:271)
              at org.eclipse.core.internal.content.ContentTypeCatalog.collectMatchingByContents(ContentTypeCatalog.java:184)
                at org.eclipse.core.internal.content.ContentTypeCatalog.internalFindContentTypesFor(ContentTypeCatalog.java:403)
                at org.eclipse.core.internal.content.ContentTypeCatalog.internalFindContentTypesFor(ContentTypeCatalog.java:450)
                at org.eclipse.core.internal.content.ContentTypeCatalog.getDescriptionFor(ContentTypeCatalog.java:346)
                at org.eclipse.core.internal.content.ContentTypeCatalog.getDescriptionFor(ContentTypeCatalog.java:360)
                at org.eclipse.core.internal.content.ContentTypeMatcher.getDescriptionFor(ContentTypeMatcher.java:86)
                at org.eclipse.core.internal.resources.ContentDescriptionManager.readDescription(ContentDescriptionManager.java:445)
                at org.eclipse.core.internal.resources.ContentDescriptionManager.getDescriptionFor(ContentDescriptionManager.java:355)
                at org.eclipse.core.internal.resources.File.internalGetCharset(File.java:246)
                at org.eclipse.core.internal.resources.File.getCharset(File.java:207)
                at org.eclipse.core.internal.resources.File.getCharset(File.java:194)
                at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(Util.java:1156)
                at org.eclipse.jdt.internal.core.builder.SourceFile.getContents(SourceFile.java:79)
                at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9874)
                at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9846)
                at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:8420)
                at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:716)
                at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:381)
                at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
                at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:364)
                at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:178)
                at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:301)
                at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:60)
                at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:254)
                at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:173)
                at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
                at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
                at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
                at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
                at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
                at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
                at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
                at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
                at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
                at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
                at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
                at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Re: SWT invalid thread access exception makes eclipse crash [message #904451 is a reply to message #904324] Tue, 28 August 2012 12:53 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
In theory Display.getDefault() can be called from any thread, not only from UI thread.
This is for what it exists - to allow to run asyncExec().

It seems however that some other thread already owns Display, or some lock inside of Display.
So, WindowBuilder can not access Display.

Fixed in trunk.
Now we use Display not in DesignerPlugin.start(), but in constructor of DesignEditor, where we run in UI thread and can access Display.


Konstantin Scheglov,
Google, Inc.
Re: SWT invalid thread access exception makes eclipse crash [message #904473 is a reply to message #904451] Tue, 28 August 2012 13:40 Go to previous message
Maxime Jeanmart is currently offline Maxime JeanmartFriend
Messages: 35
Registered: November 2010
Member
Hi Konstantin and thanks for your quick reaction. I'm not sure it's quite the same problem here. Indeed, Display.getDefault can be called from any thread. However, the first thread to call that API wins the prize and becomes the UI thread.
In this particular example, the DesignerPlugin start method is called from a JDT job thread and is the first to call Display.getDefault. Thus the job thread becomes the UI thread. Then, afterwards, the workbench fails to initialize because it assumes that the main thread is the UI thread.
Previous Topic:JavaBean Class not detected
Next Topic:why palette view is gone after re-import
Goto Forum:
  


Current Time: Fri Apr 26 23:59:57 GMT 2024

Powered by FUDForum. Page generated in 0.03122 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top