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 occurred in the LFC when generating federated reactor for Zephyr #2199

Closed
keiichibando opened this issue Feb 16, 2024 · 2 comments · Fixed by #2414
Closed
Assignees
Labels
enhancement Enhancement of existing feature zephyr
Milestone

Comments

@keiichibando
Copy link

When generating a C-lang code using the following federated reactor for Zephyr platform, the NullPointerException occurred.

target C {
    platform: "Zephyr"
}

reactor Count {
  output out: int
  state c: int = 0
  timer t(0, 1 sec)

  reaction(t) -> out {=
    lf_set(out, self->c++);
  =}
}

reactor Print {
  input in: int

  reaction(in) {=
    lf_print("Received: %d at (%lld, %d)", in->value,
        lf_time_logical_elapsed(), lf_tag().microstep
    );
  =}
}

federated reactor {
  c = new Count()
  p = new Print()
  c.out -> p.in
}

Execution command and error message:

# lfc --version
lfc 0.6.0
# lfc src/test.lf 
lfc: info: ##### Generating code for federate federate__c in directory /root/test/fed-gen/test/src
lfc: fatal error: Error running generator
java.lang.NullPointerException
        at java.base/java.util.ArrayDeque.addFirst(ArrayDeque.java:286)
        at java.base/java.util.ArrayDeque.push(ArrayDeque.java:579)
        at org.lflang.ast.ToLf.doSwitch(ToLf.java:124)
        at org.lflang.ast.ToLf.caseKeyValuePair(ToLf.java:901)
        at org.lflang.ast.ToLf.caseKeyValuePair(ToLf.java:88)
        at org.lflang.lf.util.LfSwitch.doSwitch(LfSwitch.java:296)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69)
        at org.lflang.ast.ToLf.doSwitchHelper(ToLf.java:132)
        at org.lflang.ast.ToLf.doSwitch(ToLf.java:125)
        at org.lflang.ast.ToLf.lambda$list$14(ToLf.java:1133)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
        at org.lflang.ast.ToLf.list(ToLf.java:1136)
        at org.lflang.ast.ToLf.list(ToLf.java:1105)
        at org.lflang.ast.ToLf.caseKeyValuePairs(ToLf.java:864)
        at org.lflang.ast.ToLf.caseKeyValuePairs(ToLf.java:88)
        at org.lflang.lf.util.LfSwitch.doSwitch(LfSwitch.java:289)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69)
        at org.lflang.ast.ToLf.doSwitchHelper(ToLf.java:132)
        at org.lflang.ast.ToLf.doSwitch(ToLf.java:125)
        at org.lflang.ast.ToLf.caseElement(ToLf.java:918)
        at org.lflang.ast.ToLf.caseElement(ToLf.java:88)
        at org.lflang.lf.util.LfSwitch.doSwitch(LfSwitch.java:310)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69)
        at org.lflang.ast.ToLf.doSwitchHelper(ToLf.java:132)
        at org.lflang.ast.ToLf.doSwitch(ToLf.java:125)
        at org.lflang.ast.ToLf.caseKeyValuePair(ToLf.java:901)
        at org.lflang.ast.ToLf.caseKeyValuePair(ToLf.java:88)
        at org.lflang.lf.util.LfSwitch.doSwitch(LfSwitch.java:296)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69)
        at org.lflang.ast.ToLf.doSwitchHelper(ToLf.java:132)
        at org.lflang.ast.ToLf.doSwitch(ToLf.java:125)
        at org.lflang.ast.ToLf.lambda$list$14(ToLf.java:1133)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
        at org.lflang.ast.ToLf.list(ToLf.java:1136)
        at org.lflang.ast.ToLf.list(ToLf.java:1105)
        at org.lflang.ast.ToLf.caseKeyValuePairs(ToLf.java:864)
        at org.lflang.ast.ToLf.caseKeyValuePairs(ToLf.java:88)
        at org.lflang.lf.util.LfSwitch.doSwitch(LfSwitch.java:289)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69)
        at org.lflang.ast.ToLf.doSwitchHelper(ToLf.java:132)
        at org.lflang.ast.ToLf.doSwitch(ToLf.java:125)
        at org.lflang.ast.ToLf.caseTargetDecl(ToLf.java:523)
        at org.lflang.ast.ToLf.caseTargetDecl(ToLf.java:88)
        at org.lflang.lf.util.LfSwitch.doSwitch(LfSwitch.java:123)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53)
        at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69)
        at org.lflang.ast.ToLf.doSwitchHelper(ToLf.java:132)
        at org.lflang.ast.ToLf.doSwitch(ToLf.java:125)
        at org.lflang.ast.FormattingUtil.render(FormattingUtil.java:61)
        at org.lflang.ast.FormattingUtil.lambda$renderer$0(FormattingUtil.java:51)
        at org.lflang.federated.generator.FedTargetEmitter.generateTarget(FedTargetEmitter.java:30)
        at org.lflang.federated.generator.FedEmitter.generateFederate(FedEmitter.java:51)
        at org.lflang.federated.generator.FedGenerator.doGenerate(FedGenerator.java:169)
        at org.lflang.generator.LFGenerator.doGenerate(LFGenerator.java:105)
        at org.eclipse.xtext.generator.GeneratorDelegate.doGenerate(GeneratorDelegate.java:44)
        at org.eclipse.xtext.generator.GeneratorDelegate.generate(GeneratorDelegate.java:35)
        at org.lflang.cli.Lfc.invokeGenerator(Lfc.java:242)
        at org.lflang.cli.Lfc.doRun(Lfc.java:201)
        at org.lflang.cli.CliBase.run(CliBase.java:124)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2026)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
        at picocli.CommandLine.execute(CommandLine.java:2170)
        at org.lflang.cli.CliBase.doExecute(CliBase.java:115)
        at org.lflang.cli.CliBase.cliMain(CliBase.java:107)
        at org.lflang.cli.Lfc.main(Lfc.java:189)
        at org.lflang.cli.Lfc.main(Lfc.java:179)
@erlingrj
Copy link
Collaborator

Hi @keiichibando, unfortunately, we don't have official support for federated programs using the Zephyr platform yet. It is very doable and we have successfully run some test programs with NXP iMXRT1170 EVK which has ethernet.

Did you have a concrete project in mind? I might be able to make some preliminary support for it, but not until March.

@erlingrj erlingrj added enhancement Enhancement of existing feature zephyr labels Feb 16, 2024
@lhstrh
Copy link
Member

lhstrh commented Feb 16, 2024

@keiichibando, thanks for the bug report. While we don't have official support for Zephyr yet, this should of course not result in a NPE. In the near term, we should replace this with an error message. As @erlingrj suggests, we can work on federated Zephyr support if that is a clear priority. Looking forward to hear more about your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing feature zephyr
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants