New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XpackUtils throwing a NPE when calling System Repo Base Paths #549
Comments
Just adding some more points:
@ilg-ul Please share your valuable thoughts on this. |
The NPE is definitely a bug, but I have difficulties to understand the context. Can you provide a detailed sequence of steps to reproduce the error? |
Steps to Reproduce:
Background: The toolchain mentioned in default preference is 2262347901(RISC-V GCC/Newlib). We haven't set any default preference for toolchain.xpack.names.2262347901. So the fXpackNames returned from this call : fDefaultPreferences.getToolchainXpackNames(fSelectedToolchainId, fSelectedToolchainName) (line 175 of SetCrossCommandWizardPage) will be an array with 1 value as an empty string. With this array a call is made to XpackUtils::getPackVersions which eventually calls to getSysRepoPath(). |
It seems like if we are using System.getenv("ProgramFiles") it would return the correct value. The call to System.getenv is case insensitive and the map returned by System.getenv() is case sensitive (as per the documentation). When I tried using System.getenv("ProgramFiles") directly it's working fine. Just adding the behaviour which I saw. |
What is the context of this statement? How is it related to the NPE? |
What OS and what versions of Eclipse/plug-ins? |
I am using Windows 10 machine. I tried debugging and found like we have a call to System.getenv() in XpackUtils::getSysRepoBasePaths. The System.getenv() call give a map which has all keys in UPPER CASE. And because of which env.get("ProgramFiles") is returning null and finally resulting in the NPE when passed to org.eclipse.core.runtime.Path constructor. So I think if we try to fetch the "ProgramFiles" variable using System.getenv("ProgramFiles") it will be giving the correct path (since this call is case insensitive). |
Please see the below versions of the platform. |
Could you prepare a pull request (based on the develop branch) with a version that works in your environment? |
Sure I will do that. |
[#549] Fix NPE in XpackUtils::getSysRepoBasePaths
Merged, thank you. I'll make a new release during the next few days. |
Thanks @ilg-ul. |
Description
XpackUtils throwing a NPE when calling System Repo Base Paths. When trying to create a new project from the Wizard, there is an NPE received in the last (toolchain selection) page. Please see the detailed log below.
java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" because "fullPath" is null at org.eclipse.core.runtime.Path.<init>(Path.java:231) at org.eclipse.core.runtime.Path.<init>(Path.java:189) at org.eclipse.embedcdt.core.XpackUtils.getSysRepoBasePaths(XpackUtils.java:130) at org.eclipse.embedcdt.core.XpackUtils.getSysRepoPath(XpackUtils.java:185) at org.eclipse.embedcdt.core.XpackUtils.getSysPackPath(XpackUtils.java:209) at org.eclipse.embedcdt.core.XpackUtils.getPackVersions(XpackUtils.java:253) at org.eclipse.embedcdt.ui.XpackDirectoryNotStrictFieldEditor.<init>(XpackDirectoryNotStrictFieldEditor.java:41) at org.eclipse.embedcdt.internal.managedbuild.cross.riscv.ui.preferences.GlobalToolchainsPathsPreferencesPage.createFieldEditors(GlobalToolchainsPathsPreferencesPage.java:177) at org.eclipse.jface.preference.FieldEditorPreferencePage.createContents(FieldEditorPreferencePage.java:227) at org.eclipse.jface.preference.PreferencePage.createControl(PreferencePage.java:244) at org.eclipse.jface.preference.PreferenceDialog.createPageControl(PreferenceDialog.java:1433) at org.eclipse.jface.preference.PreferenceDialog$8.run(PreferenceDialog.java:1196) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:174) at org.eclipse.jface.preference.PreferenceDialog.showPage(PreferenceDialog.java:1188) at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.showPage(FilteredPreferenceDialog.java:630) at org.eclipse.jface.preference.PreferenceDialog$5.lambda$0(PreferenceDialog.java:660) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:74) at org.eclipse.jface.preference.PreferenceDialog$5.selectionChanged(PreferenceDialog.java:657) at org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredViewer.java:821) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:174) at org.eclipse.jface.viewers.StructuredViewer.firePostSelectionChanged(StructuredViewer.java:818) at org.eclipse.jface.viewers.StructuredViewer.handlePostSelect(StructuredViewer.java:1191) at org.eclipse.swt.events.SelectionListener$1.widgetSelected(SelectionListener.java:84) at org.eclipse.jface.util.OpenStrategy.firePostSelectionEvent(OpenStrategy.java:284) at org.eclipse.jface.util.OpenStrategy$1.lambda$1(OpenStrategy.java:438) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4035) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3635) at org.eclipse.jface.window.Window.runEventLoop(Window.java:823) at org.eclipse.jface.window.Window.open(Window.java:799) at org.eclipse.ui.internal.OpenPreferencesAction.run(OpenPreferencesAction.java:66) at org.eclipse.jface.action.Action.runWithEvent(Action.java:474) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:580) at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:414) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4243) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1063) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4060) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3632) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:578) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) at org.eclipse.equinox.launcher.Main.run(Main.java:1467) at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
The text was updated successfully, but these errors were encountered: