Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 479475 - Workbench startup must not run asyncExecs until it is fully initialized
Summary: Workbench startup must not run asyncExecs until it is fully initialized
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.6 M3   Edit
Assignee: Stefan Xenos CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 241927 471908 (view as bug list)
Depends on: 479435
Blocks:
  Show dependency tree
 
Reported: 2015-10-09 21:23 EDT by Stefan Xenos CLA
Modified: 2015-10-15 14:05 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Xenos CLA 2015-10-09 21:23:33 EDT
This is really the same as bug 178875, which is still not fixed.

There is a period during workbench start up where the workbench is not yet able to honor its API contracts (specifically, until the Workbench.init() call has run to completion). The workbench must not invoke any asyncExecs until this has happened, since an asyncExec is allowed to use the workbench's public APIs which won't work at that time.

For example, calling PlatformUI.getWorkbench().getAdapter(ICommandService.class) before initialization will throw an exception... and an exception during plugin activation will often prevent Eclipse from starting.

Currently, the workbench seems to trigger these unsafe asyncExecs in two places: the event loop is pumped "for free" by the call to Display.setSynchronizer (bug 479435) and the second is around line 2955 of Workbench.java, which looks like this: 

				while (true) {
					if (!display.readAndDispatch()) {
						if (initDone)
							break;
						display.sleep();
					}
				}

As long as this remains the case, the Workbench is likely to crash on startup any time a plugin runs an asyncExec in its plugin startup code. 

Note: there is no way to make syncExecs completely safe. If they're deferred until after startup, we risk deadlock. If they're not, we risk a crash to desktop. We can make asyncExec completely safe but should also make a best effort not to make syncExec any worse than it is now.
Comment 1 Eclipse Genie CLA 2015-10-09 22:05:47 EDT
New Gerrit change created: https://git.eclipse.org/r/57891
Comment 3 Stefan Xenos CLA 2015-10-12 21:39:23 EDT
To help with triage: if you see a bug which reports a crash on startup due to a NoClassDefFoundError and a stack trace which contains either this:

        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:xxxx)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:xxxx)

...or this:

        at org.eclipse.swt.widgets.Display.setSynchronizer(Display.java:xxxx)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:xxxx)

...then it is most likely a dupe of this bug.
Comment 4 Stefan Xenos CLA 2015-10-12 21:39:45 EDT
*** Bug 471908 has been marked as a duplicate of this bug. ***
Comment 5 Stefan Xenos CLA 2015-10-12 22:48:20 EDT
Possible dupe: bug 241927
Comment 6 Stefan Xenos CLA 2015-10-12 22:50:56 EDT
*** Bug 241927 has been marked as a duplicate of this bug. ***
Comment 7 Lars Vogel CLA 2015-10-15 09:58:01 EDT
(In reply to Eclipse Genie from comment #2)
> Gerrit change https://git.eclipse.org/r/57891 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=0a0004d043ec213109226e793703783a29268b01

I assume this closes this bug for platform UI. You have a separate bug for SWT. If not, please reopen.
Comment 8 Stefan Xenos CLA 2015-10-15 14:05:20 EDT
The crashes won't go away until the SWT change goes in, too... so the bugs marked as duplicates won't really be fixed until bug 479435 is fixed.