Skip to content
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

NullPointerException when editing files #81

Closed
wandersiemers opened this issue Oct 18, 2021 · 14 comments
Closed

NullPointerException when editing files #81

wandersiemers opened this issue Oct 18, 2021 · 14 comments
Labels
C-Bug Category: bug. Not working as expected P-High Priority: high. Should take priority over low and non-prioritized

Comments

@wandersiemers
Copy link

wandersiemers commented Oct 18, 2021

Summary

The spoofax editor crashes when I make changes to a .spt test file, giving a NullPointerException on every keystroke.

What you did

Open a .spt file, make some changes, wait until the editor reloads and immediately crashes with 'SPT Editor Update'.

What you expected to happen

Editor updates and reruns tests

What actually happened

Editor crashes

Context

  • Spoofax version: 0.14.2
  • Operating system & version: MacOS 11.6
  • Java version (if applicable): embedded JVM
  • Eclipse version (if applicable): 2021-03
  • Gradle version (if applicable):

Additional information

Log of SPT Editor Update:
error-log.txt

@wandersiemers wandersiemers added the C-Bug Category: bug. Not working as expected label Oct 18, 2021
@AZWN
Copy link
Contributor

AZWN commented Oct 18, 2021

Appears to be an issue caused by deserialization. Perhaps for the record, the issue even occurred after the following steps:

  1. Close the SPT file
  2. Clean the project (without rebuild)
  3. Close Eclipse
  4. Delete pieStore
  5. Open Eclipse
  6. Build the project
  7. Open the SPT file

Which excludes deserialization after updating as a cause.

@Gohla
Copy link
Member

Gohla commented Oct 18, 2021

If deserialization fails, it defaults to an empty state and will rebuild everything, so that should not be an issue.

@Gohla
Copy link
Member

Gohla commented Oct 18, 2021

When I check out your project and open checks.spt, I get a lot of errors like:

mb.constraint.common.ConstraintAnalyzerExceptions$StrategoInvokeFail: Constraint analyzer failed unexpectedly due to failure in Stratego execution
Caused by: mb.stratego.common.StrategoExceptions$ExceptionalFail: Invoking Stratego strategy 'editor-analyze' failed exceptionally
Stratego stack trace:
	report_failure_1_0
	report_failure_0_2
	with_1_1
	origin_track_forced_1_0
	explicate_injections_chocopy_FuncDef_0_0
	with_1_1
	origin_track_forced_1_0
	explicate_injections_chocopy_TopLevelDef_0_0
	map_1_0
	with_1_1
	origin_track_forced_1_0
	explicate_injections_chocopy_Program_0_0
	pre_analyze_0_0
	map_1_0
	with_1_1
	stx__editor_analyze_2_2
	stx_editor_analyze_2_2
	editor_analyze_0_0
	editor_analyze_0_0
Stratego input term:
AnalyzeSingle(
  [ ( "spt##/chocopy/test/checks.spt!!64"
    , Added(
        Body(
          [ VarDef(ConcreteVarDef(TypedVar("a", IdType("int")), Int("2")))
          , FuncDef(
              ConcreteFuncDef(
                "func_no_args"
              , []
              , ()
              , FuncBody(
                  []
                , [Return(Plus(Id("a"), Literal(Int("2"))))]
                )
              )
            )
          ]
        , [Assignment([TargetId("b")], IdBrackets("func_no_args", []))]
        )
      )
    )
  ]
, ()
, BLOB_org.metaborg.util.task.ThreadCancel@20fc1551()
)
Caused by: org.spoofax.interpreter.core.InterpreterException: Exception during evaluation: Legal exit: return code 1
	at org.spoofax.interpreter.core.Interpreter.evaluate(Interpreter.java:113)
	at org.spoofax.interpreter.core.Interpreter.invoke(Interpreter.java:80)
	at org.strategoxt.HybridInterpreter.invoke(HybridInterpreter.java:458)
	at mb.stratego.common.StrategoRuntime.invokeOrNull(StrategoRuntime.java:169)
	at mb.stratego.common.StrategoRuntime.invokeOrNull(StrategoRuntime.java:147)
	at mb.stratego.common.StrategoRuntime.invoke(StrategoRuntime.java:56)
	at mb.constraint.common.ConstraintAnalyzer.doAnalyze(ConstraintAnalyzer.java:383)
	at mb.constraint.common.ConstraintAnalyzer.analyze(ConstraintAnalyzer.java:268)
	at mb.constraint.common.ConstraintAnalyzer.analyze(ConstraintAnalyzer.java:256)
	at mb.chocopy.task.ChocopyAnalyze.analyze(/chocopy/build/generated/sources/adapter/mb/chocopy/task/ChocopyAnalyze.java:71)
	at mb.constraint.pie.ConstraintAnalyzeTaskDef.lambda$exec$0(ConstraintAnalyzeTaskDef.java:75)
	at mb.common.result.Result.lambda$mapCatchingOrRethrow$4(Result.java:324)
	at mb.common.result.ResultUtil.tryCatchOrRethrow(ResultUtil.java:39)
	at mb.common.result.Result.mapCatchingOrRethrow(Result.java:324)
	at mb.constraint.pie.ConstraintAnalyzeTaskDef.exec(ConstraintAnalyzeTaskDef.java:73)
	at mb.constraint.pie.ConstraintAnalyzeTaskDef.exec(ConstraintAnalyzeTaskDef.java:17)
	at mb.pie.api.Task.exec(Task.java:56)
	at mb.pie.runtime.exec.TaskExecutor.execInternal(TaskExecutor.java:128)
	at mb.pie.runtime.exec.TaskExecutor.exec(TaskExecutor.java:85)
	at mb.pie.runtime.exec.TopDownRunner.exec(TopDownRunner.java:192)
	at mb.pie.runtime.exec.TopDownRunner.executeOrGetExisting(TopDownRunner.java:137)
	at mb.pie.runtime.exec.TopDownRunner.require(TopDownRunner.java:80)
	at mb.pie.runtime.exec.ExecContextImpl.require(ExecContextImpl.java:117)
	at mb.pie.runtime.exec.ExecContextImpl.require(ExecContextImpl.java:97)
	at mb.chocopy.task.ChocopyCheck.exec(/chocopy/build/generated/sources/adapter/mb/chocopy/task/ChocopyCheck.java:77)
	at mb.chocopy.task.ChocopyCheck.exec(/chocopy/build/generated/sources/adapter/mb/chocopy/task/ChocopyCheck.java:20)
	at mb.pie.api.Task.exec(Task.java:56)
	at mb.pie.runtime.exec.TaskExecutor.execInternal(TaskExecutor.java:128)
	at mb.pie.runtime.exec.TaskExecutor.exec(TaskExecutor.java:85)
	at mb.pie.runtime.exec.TopDownRunner.exec(TopDownRunner.java:192)
	at mb.pie.runtime.exec.TopDownRunner.executeOrGetExisting(TopDownRunner.java:137)
	at mb.pie.runtime.exec.TopDownRunner.require(TopDownRunner.java:80)
	at mb.pie.runtime.exec.TopDownRunner.requireInitial(TopDownRunner.java:59)
	at mb.pie.runtime.MixedSessionImpl.lambda$requireWithoutObserving$2(MixedSessionImpl.java:110)
	at mb.pie.runtime.SessionImpl.handleException(SessionImpl.java:215)
	at mb.pie.runtime.MixedSessionImpl.requireWithoutObserving(MixedSessionImpl.java:110)
	at mb.spt.expectation.CheckCountExpectation.evaluate(CheckCountExpectation.java:88)
	at mb.spt.task.SptCheck.runTests(SptCheck.java:163)
	at mb.spt.task.SptCheck.lambda$runTests$1(SptCheck.java:147)
	at mb.common.result.Result.ifThrowingElse(Result.java:235)
	at mb.spt.task.SptCheck.runTests(SptCheck.java:146)
	at mb.spt.task.SptCheck.lambda$exec$0(SptCheck.java:111)
	at mb.common.result.Result.ifThrowingElse(Result.java:235)
	at mb.spt.task.SptCheck.exec(SptCheck.java:109)
	at mb.spt.task.SptCheck.exec(SptCheck.java:41)
	at mb.pie.api.Task.exec(Task.java:56)
	at mb.pie.runtime.exec.TaskExecutor.execInternal(TaskExecutor.java:128)
	at mb.pie.runtime.exec.TaskExecutor.exec(TaskExecutor.java:85)
	at mb.pie.runtime.exec.BottomUpRunner.exec(BottomUpRunner.java:369)
	at mb.pie.runtime.exec.BottomUpRunner.getData(BottomUpRunner.java:211)
	at mb.pie.runtime.exec.BottomUpRunner.require(BottomUpRunner.java:185)
	at mb.pie.runtime.exec.BottomUpRunner.requireInitial(BottomUpRunner.java:94)
	at mb.pie.runtime.TopDownSessionImpl.lambda$require$0(TopDownSessionImpl.java:72)
	at mb.pie.runtime.SessionImpl.handleException(SessionImpl.java:215)
	at mb.pie.runtime.TopDownSessionImpl.require(TopDownSessionImpl.java:72)
	at mb.pie.api.TopDownSession.getOutputOrRequireAndEnsureExplicitlyObserved(TopDownSession.java:60)
	at mb.spoofax.eclipse.pie.PieRunner.getOrRequire(PieRunner.java:495)
	at mb.spoofax.eclipse.pie.PieRunner.addOrUpdateEditor(PieRunner.java:152)
	at mb.spoofax.eclipse.editor.EditorUpdateJob.update(EditorUpdateJob.java:97)
	at mb.spoofax.eclipse.editor.EditorUpdateJob.run(EditorUpdateJob.java:74)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.spoofax.interpreter.core.InterpreterExit: Legal exit: return code 1
	at org.strategoxt.lang.InteropSDefT.evaluate(InteropSDefT.java:196)
	at org.strategoxt.lang.InteropSDefT.evaluate(InteropSDefT.java:183)
	at org.strategoxt.lang.InteropSDefT$StrategyBody.evaluate(InteropSDefT.java:245)
	at org.spoofax.interpreter.core.Interpreter.evaluate(Interpreter.java:105)
	... 60 more
Caused by: org.strategoxt.lang.StrategoExit: Legal exit: return code 1
	at org.strategoxt.lang.Context.invokePrimitive(Context.java:221)
	at org.strategoxt.lang.Context.invokePrimitive(Context.java:201)
	at strategolib.trans.exit_0_0.invoke(exit_0_0.java:10)
	at strategolib.trans.report_failure_0_2_lifted0.invoke(report_failure_0_2_lifted0.java:18)
	at strategolib.trans.report_failure_1_0.invoke(report_failure_1_0.java:27)
	at strategolib.trans.report_failure_0_2.invoke(report_failure_0_2.java:16)
	at strategolib.trans.with_1_1.invoke(with_1_1.java:25)
	at mb.chocopy.strategies.explicate_injections_chocopy_$Func$Def_0_0_lifted0.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/explicate_injections_chocopy_$Func$Def_0_0_lifted0.java:45)
	at org.strategoxt.lang.SRTS_all.mapMaintainAnnos(SRTS_all.java:90)
	at org.strategoxt.lang.SRTS_all.invoke(SRTS_all.java:23)
	at mb.chocopy.strategies.origin_track_forced_1_0.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/origin_track_forced_1_0.java:14)
	at mb.chocopy.strategies.explicate_injections_chocopy_$Func$Def_0_0.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/explicate_injections_chocopy_$Func$Def_0_0.java:23)
	at mb.chocopy.strategies.explicate_injections_chocopy_$Top$Level$Def_0_0_lifted3.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/explicate_injections_chocopy_$Top$Level$Def_0_0_lifted3.java:12)
	at strategolib.trans.with_1_1.invoke(with_1_1.java:17)
	at mb.chocopy.strategies.explicate_injections_chocopy_$Top$Level$Def_0_0_lifted2.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/explicate_injections_chocopy_$Top$Level$Def_0_0_lifted2.java:27)
	at org.strategoxt.lang.SRTS_all.mapMaintainAnnos(SRTS_all.java:90)
	at org.strategoxt.lang.SRTS_all.invoke(SRTS_all.java:23)
	at mb.chocopy.strategies.origin_track_forced_1_0.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/origin_track_forced_1_0.java:14)
	at mb.chocopy.strategies.explicate_injections_chocopy_$Top$Level$Def_0_0.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/explicate_injections_chocopy_$Top$Level$Def_0_0.java:28)
	at strategolib.trans.map_1_0_x0.invoke(map_1_0_x0.java:28)
	at org.strategoxt.lang.Strategy.invokeDynamic(Strategy.java:33)
	at org.strategoxt.lang.gradual.Proxy.invokeDynamic(Proxy.java:42)
	at org.strategoxt.lang.gradual.Proxy.invoke(Proxy.java:55)
	at strategolib.trans.map_1_0.invoke(map_1_0.java:36)
	at mb.chocopy.strategies.explicate_injections_chocopy_$Program_0_0_lifted1.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/explicate_injections_chocopy_$Program_0_0_lifted1.java:14)
	at strategolib.trans.with_1_1.invoke(with_1_1.java:17)
	at mb.chocopy.strategies.explicate_injections_chocopy_$Program_0_0_lifted0.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/explicate_injections_chocopy_$Program_0_0_lifted0.java:33)
	at org.strategoxt.lang.SRTS_all.mapMaintainAnnos(SRTS_all.java:90)
	at org.strategoxt.lang.SRTS_all.invoke(SRTS_all.java:23)
	at mb.chocopy.strategies.origin_track_forced_1_0.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/origin_track_forced_1_0.java:14)
	at mb.chocopy.strategies.explicate_injections_chocopy_$Program_0_0.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/explicate_injections_chocopy_$Program_0_0.java:19)
	at mb.chocopy.strategies.pre_analyze_0_0.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/pre_analyze_0_0.java:11)
	at mb.chocopy.strategies.stx__editor_analyze_2_2_lifted5.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/stx__editor_analyze_2_2_lifted5.java:16)
	at strategolib.trans.map_1_0.invoke(map_1_0.java:29)
	at mb.chocopy.strategies.stx__editor_analyze_2_2_lifted1.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/stx__editor_analyze_2_2_lifted1.java:31)
	at strategolib.trans.with_1_1.invoke(with_1_1.java:17)
	at mb.chocopy.strategies.stx__editor_analyze_2_2.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/stx__editor_analyze_2_2.java:72)
	at mb.chocopy.strategies.stx_editor_analyze_2_2.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/stx_editor_analyze_2_2.java:11)
	at mb.chocopy.strategies.editor_analyze_0_0.invoke(/chocopy/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/editor_analyze_0_0.java:20)
	at org.strategoxt.lang.Strategy.invokeDynamic(Strategy.java:33)
	at org.strategoxt.lang.InteropSDefT.evaluate(InteropSDefT.java:192)
	... 63 more

I traced this down to the SDF3 rule: ReturnType = <> which is invalid (but does not give an error, which is a bug). That production should be given a constructor like ReturnType.NoReturnType = <>.

I cannot reproduce the NullPointerException though.

@wandersiemers
Copy link
Author

Thanks for checking out my project. I'll update the rule you refer to and I'll keep an eye on the editor updates to see if can give you more specifics about the exception.

@Gohla
Copy link
Member

Gohla commented Oct 18, 2021

There was another SDF3 rule with the same problem: ClassBody = <pass> should be ClassBody.BodyPass = <pass>

@Gohla
Copy link
Member

Gohla commented Oct 21, 2021

I've fixed a bug in 0.15.1 that might cause these NullPointerExceptions, can you try that out?

@Gohla Gohla added the P-High Priority: high. Should take priority over low and non-prioritized label Oct 21, 2021
@ThijsRay
Copy link

I run into NullPointerExceptions with version 0.15.2 when I open correctness.spt (link to my project on GitLab). It happens whenever I open, edit or save this file. Previously, I was using version 0.14.2. That version did not have this issue.

@Gohla
Copy link
Member

Gohla commented Oct 22, 2021

@ThijsRay damn, but I was at least able to trigger it with your project on my machine, and hopefully have a fix coming soon, thanks!

You can temporarily downgrade to an older version by uninstalling the Spoofax plugin (Help -> Install New Software... -> Click "what is already installed" -> click the plugin without a name and with id spoofax.lwb.eclipse.feature.feature.group -> press Uninstall...), and installing Spoofax again from the update site for that version, for example https://artifacts.metaborg.org/content/unzip/releases-unzipped/org/metaborg/spoofax.lwb.eclipse.repository/0.14.2/spoofax.lwb.eclipse.repository-0.14.2.zip-unzip/ for 0.14.2.

@Gohla
Copy link
Member

Gohla commented Oct 22, 2021

I've fixed another bug in 0.15.3 that causes these NullPointerExceptions, can you try that out?

@ThijsRay
Copy link

Thank you for the quick response! While it does seem to fix the NullPointerException, the same file causes the syntax highlighting to break and causes the SPT Test Runner to go into something that seems like an infinite loop. The offending tests in the same correctness.spt file are

  • test list assign homogeneous
  • test list assign hetrogeneous assign
  • test hetrogeneous list assign value

Removing these tests fixes this issue, but commenting them out does not seem to work for me.

@Gohla
Copy link
Member

Gohla commented Oct 22, 2021

@ThijsRay What do you mean by "commenting them out does not seem to work for me"? I noticed the infinite loop in those tests as well. That is caused by an infinite loop in analysis, possibly due to your Statix specification. Take a look at those tests and related constraints in your Statix specification to check if there is anything wrong. If you can't figure it out, ask for help on Mattermost, @AZWN can probably help you with this.

@Fastjur
Copy link

Fastjur commented Oct 22, 2021

I just had a StackOverflow occur. I am on version 0.15.2. Here is the log file:
bak_0 copy.log

@AZWN
Copy link
Contributor

AZWN commented Oct 23, 2021

@Gohla Perhaps we should add -XX:MaxJavaStackTraceDepth=-1 to the JVM arguments, to see the bottom of these traces.

@Gohla Gohla changed the title Editor crash when editing test file NullPointerException when editing files Oct 25, 2021
@Gohla
Copy link
Member

Gohla commented Oct 25, 2021

I'm closing this issue as the intermittent NullPointerException problem seems to be solved in 0.15.3. Please comment only on this issue if you still get intermittent NullPointerExceptions in 0.15.3 or higher. Otherwise, create a new issue.

@Gohla Gohla closed this as completed Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug Category: bug. Not working as expected P-High Priority: high. Should take priority over low and non-prioritized
Projects
None yet
Development

No branches or pull requests

5 participants