Null pointer in Stratego outliner during editing
Sometimes when editing Stratego an
NPE
is issued. This seems to be some interaction with error recovery and origin tracking. The stack trace is:java.lang.NullPointerException at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.runtime.stratego.StrategoTermPath.getTermPathWithOrigin(StrategoTermPath.java:177) at org.strategoxt.imp.runtime.services.views.outline.SpoofaxOutlinePage.textSelectionToOutlineSelection(SpoofaxOutlinePage.java:153) at org.strategoxt.imp.runtime.services.views.outline.SpoofaxOutlinePage.selectionChanged(SpoofaxOutlinePage.java:119) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:164) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:162) at org.eclipse.jface.text.TextViewer.fireSelectionChanged(TextViewer.java:2738) at org.eclipse.jface.text.TextViewer.selectionChanged(TextViewer.java:2717) at org.eclipse.jface.text.TextViewer.setSelectedRange(TextViewer.java:2402) at org.eclipse.jface.text.link.LinkedModeUI.select(LinkedModeUI.java:933) at org.eclipse.jface.text.link.LinkedModeUI.switchPosition(LinkedModeUI.java:851) at org.eclipse.jface.text.link.LinkedModeUI.next(LinkedModeUI.java:798) at org.eclipse.jface.text.link.LinkedModeUI.enter(LinkedModeUI.java:717) at org.strategoxt.imp.runtime.services.ContentProposal$1.runInUIThread(ContentProposal.java:209) at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3946) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3623) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) 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:353) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584) at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
Unfortunately i do not have a reliable way of recreating the issue, yet.
Submitted by Vlad Vergu on 29 October 2013 at 16:08
Issue Log
It’s hard to tell where this error comes from, so it would be great if we can figure out how to reproduce it. The terms passed to
StrategoTermPath.getTermPathWithOrigin(...)
by the outline cannot benull
, so either the passed selection term has no origin because of a bug inEditorState.getSelectionAst(...)
, or there is a bug inStrategoTermPath.getTermPathWithOrigin(...)
.Both methods also produce
IndexOutOfBoundsExceptions
, which are currently caught and handled by the outline, a quick and dirty hack. This should also be fixed properly.
I understand. I’ll keep an eye out for this happening again, and hopefully figure out a way to recreate.
To avoid the NPE, I’m now catching it and showing it in the Error Log instead.
The error will also include the input on which strategyposition-of-term
fails, which may allow us to figure out what the real issue is.
I got this NPE today while trying to reproduce https://yellowgrass.org/issue/Spoofax/840. I had 6 instances of this, here’s the data from the error log:
Spoofax/757: position-of-term failed for input: (Form("Problems"{Def(URI(Language("QL"),[ID(NablNsForm,"Problems",Unique("/Users/gohla/Spoofax/Repositories/bitbucket.org/lwc2013/QL-examples/vehicle-checkin/problems.ql/0"))]))},[Question("probs"{Def(URI(Language("QL"),[ID(NablNsQuestion,"probs",NonUnique),ID(NablNsForm,"Problems",Unique("/Users/gohla/Spoofax/Repositories/bitbucket.org/lwc2013/QL-examples/vehicle-checkin/problems.ql/0"))]))},Label("\"Problems?\""),BoolTy),Conditional(Ref("probs"{Use(Result(40))}){(Type,Result(323))},[Question("sinceP"{Def(URI(Language("QL"),[ID(NablNsQuestion,"sinceP",NonUnique),ID(NablNsForm,"Problems",Unique("/Users/gohla/Spoofax/Repositories/bitbucket.org/lwc2013/QL-examples/vehicle-checkin/problems.ql/0"))]))},Label("\"Since?\""),DateTy),Question("engineP"{Def(URI(Language("QL"),[ID(NablNsQuestion,"engineP",NonUnique),ID(NablNsForm,"Problems",Unique("/Users/gohla/Spoofax/Repositories/bitbucket.org/lwc2013/QL-examples/vehicle-checkin/problems.ql/0"))]))},Label("\"Engine?\""),BoolTy),Question("drivetP"{Def(URI(Language("QL"),[ID(NablNsQuestion,"drivetP",NonUnique),ID(NablNsForm,"Problems",Unique("/Users/gohla/Spoofax/Repositories/bitbucket.org/lwc2013/QL-examples/vehicle-checkin/problems.ql/0"))]))},Label("\"Drivetrain?\""),BoolTy),Question("bodyP"{Def(URI(Language("QL"),[ID(NablNsQuestion,"bodyP",NonUnique),ID(NablNsForm,"Problems",Unique("/Users/gohla/Spoofax/Repositories/bitbucket.org/lwc2013/QL-examples/vehicle-checkin/problems.ql/0"))]))},Label("\"Body?\""),BoolTy)]),Conditional(Ref("probs"{Use(Result(40))}){(Type,Result(323))},[Question("since"{Def(URI(Language("QL"),[ID(NablNsQuestion,"since",NonUnique),ID(NablNsForm,"Problems",Unique("/Users/gohla/Spoofax/Repositories/bitbucket.org/lwc2013/QL-examples/vehicle-checkin/problems.ql/0"))]))},Label("\"Since\""),DateTy)]),Conditional(Ref("engineP"{Use(Result(44))}){(Type,Result(330))},[Question("desEngP"{Def(URI(Language("QL"),[ID(NablNsQuestion,"desEngP",NonUnique),ID(NablNsForm,"Problems",Unique("/Users/gohla/Spoofax/Repositories/bitbucket.org/lwc2013/QL-examples/vehicle-checkin/problems.ql/0"))]))},Label("\"Describe\""),StringTy)]),Conditional(Ref("drivetP"{Use(Result(47))}){(Type,Result(336))},[Question("desDrvP"{Def(URI(Language("QL"),[ID(NablNsQuestion,"desDrvP",NonUnique),ID(NablNsForm,"Problems",Unique("/Users/gohla/Spoofax/Repositories/bitbucket.org/lwc2013/QL-examples/vehicle-checkin/problems.ql/0"))]))},Label("\"Describe\""),StringTy)]),Conditional(Ref("bodyP"{Use(Result(49))}){(Type,Result(342))},[Question("desBdyP"{Def(URI(Language("QL"),[ID(NablNsQuestion,"desBdyP",NonUnique),ID(NablNsForm,"Problems",Unique("/Users/gohla/Spoofax/Repositories/bitbucket.org/lwc2013/QL-examples/vehicle-checkin/problems.ql/0"))]))},Label("\"Describe\""),StringTy)])]), TestOrigin) java.lang.NullPointerException at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.runtime.stratego.StrategoTermPath.getTermPathWithOrigin(StrategoTermPath.java:179) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:100) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:94) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTerm(InputTermBuilder.java:83) at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:89) at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68) at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) java.lang.NullPointerException at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.runtime.stratego.StrategoTermPath.getTermPathWithOrigin(StrategoTermPath.java:179) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:100) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:94) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTerm(InputTermBuilder.java:83) at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:89) at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68) at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) java.lang.NullPointerException at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.runtime.stratego.StrategoTermPath.getTermPathWithOrigin(StrategoTermPath.java:179) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:100) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:94) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTerm(InputTermBuilder.java:83) at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:89) at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68) at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) java.lang.NullPointerException at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.runtime.stratego.StrategoTermPath.getTermPathWithOrigin(StrategoTermPath.java:179) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:100) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:94) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTerm(InputTermBuilder.java:83) at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:89) at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68) at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) java.lang.NullPointerException at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.runtime.stratego.StrategoTermPath.getTermPathWithOrigin(StrategoTermPath.java:179) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:100) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:94) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTerm(InputTermBuilder.java:83) at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:89) at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68) at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) java.lang.NullPointerException at org.strategoxt.imp.generator.position_of_term_1_1.invoke(position_of_term_1_1.java) at org.strategoxt.imp.generator.position_of_term_1_0.invoke(position_of_term_1_0.java) at org.strategoxt.imp.runtime.stratego.StrategoTermPath.getTermPathWithOrigin(StrategoTermPath.java:179) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:100) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTermResultingAst(InputTermBuilder.java:94) at org.strategoxt.imp.runtime.services.InputTermBuilder.makeInputTerm(InputTermBuilder.java:83) at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:89) at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68) at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Fixed with https://yellowgrass.org/issue/Spoofax/840
Log in to post comments