Bug 204365 - NPE in Builder.getDefaultOutputSettings()
Summary: NPE in Builder.getDefaultOutputSettings()
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build (show other bugs)
Version: 4.0.1   Edit
Hardware: PC Linux
: P3 critical (vote)
Target Milestone: 4.0.1   Edit
Assignee: Oleg Krasilnikov CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-09-22 17:31 EDT by Sergey Prigogin CLA
Modified: 2008-06-22 02:22 EDT (History)
1 user (show)

See Also:


Attachments
Possible fix (989 bytes, patch)
2007-09-24 01:23 EDT, Sergey Prigogin CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Prigogin CLA 2007-09-22 17:31:02 EDT
On September 12 the following code fragment was added to Builder.getDefaultOutputSettings():
		IPath path = ManagedBuildManager.getBuildFullPath(cfg, this);
		IProject proj = cfg.getOwner().getProject();
		IPath projFullPath = proj.getFullPath(); 
		if(projFullPath.isPrefixOf(path)){
			path = path.removeFirstSegments(projFullPath.segmentCount()).makeRelative();
		} else {
			path = Path.EMPTY;
		}

When build directory is outside of the workspace and is not linked to from the workspace, ManagedBuildManager.getBuildFullPath((cfg, this) returns null and projFullPath.isPrefixOf(path) throws an NPE. To reproduce, create a project and try to set build directory to /tmp. This exception should be considered a show stopper since it prevents CDT from opening any project that has build directory outside workspace.

Adding a simple check:
		if (path != null && projFullPath.isPrefixOf(path)) {
seems to help, but I don't understand the logic of this code and therefore not sure if this is a right solution.

Here is the call stack for reference:
java.lang.NullPointerException
at org.eclipse.core.runtime.Path.isPrefixOf(Path.java:630)
at org.eclipse.cdt.managedbuilder.internal.core.Builder.getDefaultOutputSettings(Builder.java:2641)
at org.eclipse.cdt.managedbuilder.internal.core.Builder.getOutputEntries(Builder.java:2627)
at org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildBuildData.getOutputDirectories(BuildBuildData.java:48)
at org.eclipse.cdt.core.settings.model.extension.impl.CDefaultBuildData.copySettingsFrom(CDefaultBuildData.java:56)
at org.eclipse.cdt.internal.core.settings.model.CBuildSettingCache.<init>(CBuildSettingCache.java:43)
at org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache.copyBuildData(CConfigurationDescriptionCache.java:194)
at org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData.copySettingsFrom(CDefaultConfigurationData.java:106)
at org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache.applyData(CConfigurationDescriptionCache.java:144)
at org.eclipse.cdt.internal.core.settings.model.CProjectDescription.applyDatas(CProjectDescription.java:217)
at org.eclipse.cdt.internal.core.settings.model.SetCProjectDescriptionOperation.executeOperation(SetCProjectDescriptionOperation.java:69)
at org.eclipse.cdt.internal.core.model.CModelOperation.execute(CModelOperation.java:342)
at org.eclipse.cdt.internal.core.model.CModelOperation.run(CModelOperation.java:607)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797)
at org.eclipse.cdt.internal.core.model.CModelOperation.runOperation(CModelOperation.java:639)
at org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.setProjectDescription(CProjectDescriptionManager.java:1250)
at org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.setProjectDescription(CProjectDescriptionManager.java:1213)
at org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.setProjectDescription(CProjectDescriptionManager.java:1206)
at org.eclipse.cdt.core.model.CoreModel.setProjectDescription(CoreModel.java:1374)
at org.eclipse.cdt.ui.newui.CDTPropertyManager.performOkForced(CDTPropertyManager.java:128)
at org.eclipse.cdt.ui.newui.CDTPropertyManager.performOk(CDTPropertyManager.java:102)
at org.eclipse.cdt.ui.newui.AbstractPage$5.run(AbstractPage.java:508)
at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:68)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:101)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:113)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:369)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:313)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:495)
at org.eclipse.cdt.ui.newui.AbstractPage.performSave(AbstractPage.java:517)
at org.eclipse.cdt.ui.newui.AbstractPage.performOk(AbstractPage.java:448)
at org.eclipse.jface.preference.PreferenceDialog$12.run(PreferenceDialog.java:926)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:857)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:46)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:199)
at org.eclipse.jface.preference.PreferenceDialog.okPressed(PreferenceDialog.java:906)
at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.okPressed(FilteredPreferenceDialog.java:374)
at org.eclipse.jface.preference.PreferenceDialog.buttonPressed(PreferenceDialog.java:233)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:616)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1101)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3319)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
at org.eclipse.jface.window.Window.open(Window.java:796)
at org.eclipse.ui.dialogs.PropertyDialogAction.run(PropertyDialogAction.java:156)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:546)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1101)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3319)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
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:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
Comment 1 Sergey Prigogin CLA 2007-09-24 01:23:48 EDT
Created attachment 79051 [details]
Possible fix

I'm not sure this is the correct fix, but it at eliminates all visible symptoms of the problem.
Comment 2 Oleg Krasilnikov CLA 2007-09-24 10:09:30 EDT
Sergey,
Your fix will be applied soon.
Comment 3 Oleg Krasilnikov CLA 2007-09-24 10:11:16 EDT
Done.