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

Bug 317340

Summary: [Compatibility] NPE thrown when altering active shell between a dialog's content assist popup and an editor
Product: [Eclipse Project] e4 Reporter: Remy Suen <remy.suen>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 1.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
core dump from linux
none
Code dump 2 none

Description Remy Suen CLA 2010-06-18 17:35:45 EDT
1. Open a file with the text editor.
2. Ctrl+F
3. Turn on 'Regular expressions'.
4. Invoke Ctrl+Space in the 'Find' text field.
5. Click on an entry in the popup.
6. Click inside the editor in the "background".
7. An NPE occurs.

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
	at org.eclipse.swt.SWT.error(SWT.java:4083)
	at org.eclipse.swt.SWT.error(SWT.java:3998)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:137)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:650)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:578)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:102)
	at org.eclipse.ui.internal.Workbench$3.run(Workbench.java:537)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:521)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Caused by: java.lang.NullPointerException
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.match(ModelServiceImpl.java:64)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.findElementsRecursive(ModelServiceImpl.java:84)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.findElements(ModelServiceImpl.java:136)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.find(ModelServiceImpl.java:150)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.isInContainer(PartServiceImpl.java:322)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:353)
	at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:105)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer$ActivationJob.run(StackRenderer.java:89)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
	... 24 more
Comment 1 Remy Suen CLA 2010-06-18 17:38:19 EDT
Trace of the root container being set to null on win32.

Thread [main] (Suspended (breakpoint at line 100 in PartServiceImpl))	
	PartServiceImpl.setRootContainer(MElementContainer) line: 100	
	GeneratedMethodAccessor9.invoke(Object, Object[]) line: not available	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 597	
	MethodRequestor.execute() line: 42	
	ContextObjectSupplier$ContextInjectionListener.update(IEclipseContext, int, Object[], IContextRecorder) line: 75	
	TrackableComputationExt.update(ContextChangeEvent) line: 87	
	EclipseContext.processScheduled(List<Scheduled>) line: 334	
	EclipseContext.set(String, Object) line: 351	
	ShellActivationListener$1.run() line: 93	
	SafeRunner.run(ISafeRunnable) line: 42	
	ShellActivationListener.activate(Shell) line: 91	
	ShellActivationListener.handleEvent(Event) line: 78	
	EventTable.sendEvent(Event) line: 84	
	Display.filterEvent(Event) line: 1253	
	Shell(Widget).sendEvent(Event) line: 1052	
	Shell(Widget).sendEvent(int, Event, boolean) line: 1077	
	Shell(Widget).sendEvent(int) line: 1058	
	Shell(Decorations).WM_ACTIVATE(int, int) line: 1635	
	Shell.WM_ACTIVATE(int, int) line: 2114	
	Shell(Control).windowProc(int, int, int, int) line: 4157	
	Shell(Canvas).windowProc(int, int, int, int) line: 341	
	Shell(Decorations).windowProc(int, int, int, int) line: 1598	
	Shell.windowProc(int, int, int, int) line: 2038	
	Display.windowProc(int, int, int, int) line: 4873	
	OS.DestroyWindow(int) line: not available [native method]	
	Shell(Control).destroyWidget() line: 684	
	Shell.destroyWidget() line: 697	
	Shell(Widget).release(boolean) line: 818	
	Shell(Widget).dispose() line: 446	
	Shell(Decorations).dispose() line: 447	
	Shell.dispose() line: 714	
	ContentProposalAdapter$ContentProposalPopup(Window).close() line: 335	
	ContentProposalAdapter$ContentProposalPopup(PopupDialog).close() line: 1191	
	ContentProposalAdapter$ContentProposalPopup.close() line: 915	
	ContentProposalAdapter$ContentProposalPopup$PopupCloserListener.handleEvent(Event) line: 132	
	EventTable.sendEvent(Event) line: 84	
	Shell(Widget).sendEvent(Event) line: 1053	
	Shell(Widget).sendEvent(int, Event, boolean) line: 1077	
	Shell(Widget).sendEvent(int) line: 1058	
	Shell(Decorations).WM_ACTIVATE(int, int) line: 1647	
	Shell.WM_ACTIVATE(int, int) line: 2114	
	Shell(Control).windowProc(int, int, int, int) line: 4157	
	Shell(Canvas).windowProc(int, int, int, int) line: 341	
	Shell(Decorations).windowProc(int, int, int, int) line: 1598	
	Shell.windowProc(int, int, int, int) line: 2038	
	Display.windowProc(int, int, int, int) line: 4873	
	OS.PeekMessageW(MSG, int, int, int, int) line: not available [native method]	
	OS.PeekMessage(MSG, int, int, int, int) line: 3024	
	Display.readAndDispatch() line: 3652	
	PartRenderingEngine$4.run() line: 650	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 578	
	E4Workbench.createAndRunUI(MApplicationElement) line: 102	
	Workbench$3.run() line: 537	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 521	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 115	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 369	
	EclipseStarter.run(String[], Runnable) line: 179	
	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: 597	
	Main.invokeFramework(String[], URL[]) line: 619	
	Main.basicRun(String[]) line: 574	
	Main.run(String[]) line: 1407	
	Main.main(String[]) line: 1383
Comment 2 Paul Webster CLA 2010-06-18 17:42:21 EDT
Created attachment 172261 [details]
core dump from linux 

When I do this on linux, I get a core dump.

PW
Comment 3 Remy Suen CLA 2010-06-20 18:55:13 EDT
The cause of this error comes from the presence of nested dialogs (one parented off the other). When the topmost dialog is disposed, we ask its parent context to reparent itself to the "last known valid child" (per se). But this value may not necessarily be set and so this becomes a no-op. However, the parent context is still pointing at the topmost dialog's context as its active child.

The topmost dialog's context is subsequently disposed and all our code that goes down the active chain to query for values will get 'null' back because the chain was never broken (as indicated above) and the bottommost context is a context that has been disposed.
Comment 4 Remy Suen CLA 2010-07-07 07:32:01 EDT
Cannot reproduce anymore with I20100706-2130.

I'm pretty sure this has been fixed due to bug 316950. Paul, do you still crash or no?
Comment 5 Paul Webster CLA 2010-07-07 08:33:30 EDT
Created attachment 173641 [details]
Code dump 2

When I tried this today, I got another core dump

PW
Comment 6 Paul Webster CLA 2010-07-07 08:42:13 EDT
(In reply to comment #5)
> Created an attachment (id=173641) [details]
> Code dump 2

This appears to be a 3.6 problem, I've opened bug 319119

PW
Comment 7 Remy Suen CLA 2010-07-07 08:45:58 EDT
(In reply to comment #6)
> This appears to be a 3.6 problem, I've opened bug 319119

Well, we'll wrap this one up then.