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

Task with same key is visited with different input when changing SDF3 source directory #116

Open
MeAmAnUsername opened this issue Jun 1, 2022 · 1 comment
Labels
C-Bug Category: bug. Not working as expected

Comments

@MeAmAnUsername
Copy link

Summary

I changed my main source directory from unspecified (i.e. ./src) to ./src/syntax and moved the Start.sdf3 file there. On building the project (Command+B) the build failed with the exception that a task was required twice with the same key but different input.

What you did

  1. Create new project
  2. Build
  3. create a directory ./src/syntax
  4. Move Start.sdf3 to ./src/syntax
  5. Edit sdf3 section in spoofaxc.cfg to
sdf3 {
  source = files {
    main-source-directory = ./src/syntax
  }
}
  1. Build

What you expected to happen

Project builds successfully both times

What actually happened

Second build fails with an exception: "Visited task with same key was required with different input in same session" (see log below)

Context

  • Spoofax version: Spoofax-pie 0.19.2
  • Operating system & version: MacOS Mojave, 10.14.6 (18G9323)
  • Java version (if applicable): 11 (bundled with Spoofax)
  • Eclipse version (if applicable): 4.23.0.20220310-1200
  • Gradle version (if applicable): N.A.

Additional information

Exception:

10:34:04.936 | INFO  | Worker-223: Building Workspace                     | mb.pie.runtime.tracer.LoggingTracer                | ← [0.807329] exception: mb.pie.runtime.layer.ValidationException: Visited task with same key was required with different input in same session. Cause:\ntask with key\n  #mb.sdf3.task.spec.Sdf3ParseTableToFile(Sdf3ParseTableToFile$Key{atermOutputFile=eclipse-resource##/rpgdsl/build/generated/resources/metalang/mb/rpgdsl/sdf.tbl, persistedOutputFile=eclipse-resource##/rpgdsl/build/generated/resources/metalang/mb/rpgdsl/sdf.bin})\nwas already visited with input\n  Sdf3ParseTableToFile$Input{parseTableSupplier=mb.sdf3.task.spec.Sdf3SpecToParseTable(Sdf3SpecToParseTable$Input{config=Sdf3SpecConfig{rootDirectory=eclipse-resource##/rpgdsl, mainSourceDirectory=eclipse-resource##/rpgdsl/src, mainFile=eclipse-resource##/rpgdsl/src/start.sdf3, includeDirectories=[], sourceFileOrigins=[mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3ResolveDependencies(ResolveDependencies$Input{rootDirectory=eclipse-resource##/rpgdsl, unarchiveDirectoryBase=eclipse-resource##/rpgdsl/build/unarchive/sdf3})], parseTableConfig=org.metaborg.sdf2table.parsetable.ParseTable...
mb.pie.runtime.layer.ValidationException: Visited task with same key was required with different input in same session. Cause:
task with key
  #mb.sdf3.task.spec.Sdf3ParseTableToFile(Sdf3ParseTableToFile$Key{atermOutputFile=eclipse-resource##/rpgdsl/build/generated/resources/metalang/mb/rpgdsl/sdf.tbl, persistedOutputFile=eclipse-resource##/rpgdsl/build/generated/resources/metalang/mb/rpgdsl/sdf.bin})
was already visited with input
  Sdf3ParseTableToFile$Input{parseTableSupplier=mb.sdf3.task.spec.Sdf3SpecToParseTable(Sdf3SpecToParseTable$Input{config=Sdf3SpecConfig{rootDirectory=eclipse-resource##/rpgdsl, mainSourceDirectory=eclipse-resource##/rpgdsl/src, mainFile=eclipse-resource##/rpgdsl/src/start.sdf3, includeDirectories=[], sourceFileOrigins=[mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3ResolveDependencies(ResolveDependencies$Input{rootDirectory=eclipse-resource##/rpgdsl, unarchiveDirectoryBase=eclipse-resource##/rpgdsl/build/unarchive/sdf3})], parseTableConfig=org.metaborg.sdf2table.parsetable.ParseTableConfiguration@ba1ad8e7}, createCompletionTable=false}), atermOutputFile=eclipse-resource##/rpgdsl/build/generated/resources/metalang/mb/rpgdsl/sdf.tbl, persistedOutputFile=eclipse-resource##/rpgdsl/build/generated/resources/metalang/mb/rpgdsl/sdf.bin}
while now required with input
  Sdf3ParseTableToFile$Input{parseTableSupplier=mb.sdf3.task.spec.Sdf3SpecToParseTable(Sdf3SpecToParseTable$Input{config=Sdf3SpecConfig{rootDirectory=eclipse-resource##/rpgdsl, mainSourceDirectory=eclipse-resource##/rpgdsl/src/syntax, mainFile=eclipse-resource##/rpgdsl/src/syntax/start.sdf3, includeDirectories=[], sourceFileOrigins=[mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3ResolveDependencies(ResolveDependencies$Input{rootDirectory=eclipse-resource##/rpgdsl, unarchiveDirectoryBase=eclipse-resource##/rpgdsl/build/unarchive/sdf3})], parseTableConfig=org.metaborg.sdf2table.parsetable.ParseTableConfiguration@ba1ad8e7}, createCompletionTable=false}), atermOutputFile=eclipse-resource##/rpgdsl/build/generated/resources/metalang/mb/rpgdsl/sdf.tbl, persistedOutputFile=eclipse-resource##/rpgdsl/build/generated/resources/metalang/mb/rpgdsl/sdf.bin}
	at mb.pie.runtime.layer.ValidationLayer.error(ValidationLayer.java:466)
	at mb.pie.runtime.layer.ValidationLayer.validateVisited(ValidationLayer.java:187)
	at mb.pie.runtime.exec.BottomUpRunner.getData(BottomUpRunner.java:250)
	at mb.pie.runtime.exec.BottomUpRunner.require(BottomUpRunner.java:234)
	at mb.pie.runtime.exec.ExecContextImpl.require(ExecContextImpl.java:118)
	at mb.pie.runtime.exec.ExecContextImpl.require(ExecContextImpl.java:98)
	at mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3Compile.compileFromSourceFiles(SpoofaxSdf3Compile.java:91)
	at mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3Compile.lambda$compile$2(SpoofaxSdf3Compile.java:74)
	at mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3Configs$LambdaCases.files(SpoofaxSdf3Configs.java:98)
	at mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3Configs$Files.match(SpoofaxSdf3Configs.java:125)
	at mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3Configs$CaseOfMatchers$TotalMatcher_Prebuilt.prebuilt(SpoofaxSdf3Configs.java:291)
	at mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3Compile.compile(SpoofaxSdf3Compile.java:75)
	at mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3Compile.lambda$exec$0(SpoofaxSdf3Compile.java:63)
	at mb.common.option.Option.mapOr(Option.java:130)
	at mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3Compile.lambda$exec$1(SpoofaxSdf3Compile.java:62)
	at mb.common.option.Option.mapOrElse(Option.java:146)
	at mb.common.result.Result.flatMap(Result.java:417)
	at mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3Compile.exec(SpoofaxSdf3Compile.java:62)
	at mb.spoofax.lwb.compiler.sdf3.SpoofaxSdf3Compile.exec(SpoofaxSdf3Compile.java:26)
	at mb.pie.api.Task.exec(Task.java:56)
	at mb.pie.runtime.exec.TaskExecutor.execInternal(TaskExecutor.java:130)
	at mb.pie.runtime.exec.TaskExecutor.exec(TaskExecutor.java:87)
	at mb.pie.runtime.exec.BottomUpRunner.exec(BottomUpRunner.java:419)
	at mb.pie.runtime.exec.BottomUpRunner.execAndSchedule(BottomUpRunner.java:132)
	at mb.pie.runtime.exec.BottomUpRunner.execScheduled(BottomUpRunner.java:119)
	at mb.pie.runtime.exec.BottomUpRunner.requireInitial(BottomUpRunner.java:82)
	at mb.pie.runtime.MixedSessionImpl.lambda$updateAffectedBy$0(MixedSessionImpl.java:72)
	at mb.pie.runtime.SessionImpl.handleException(SessionImpl.java:233)
	at mb.pie.runtime.MixedSessionImpl.updateAffectedBy(MixedSessionImpl.java:72)
	at mb.spoofax.lwb.eclipse.SpoofaxLwbBuilder.bottomUpBuild(SpoofaxLwbBuilder.java:132)
	at mb.spoofax.lwb.eclipse.SpoofaxLwbBuilderBase.incrBuild(SpoofaxLwbBuilderBase.java:88)
	at mb.spoofax.lwb.eclipse.SpoofaxLwbBuilderBase$1.run(SpoofaxLwbBuilderBase.java:59)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2292)
	at mb.spoofax.lwb.eclipse.SpoofaxLwbBuilderBase.build(SpoofaxLwbBuilderBase.java:68)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:846)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:229)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:277)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:330)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:333)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:385)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:406)
	at org.eclipse.core.internal.resources.Workspace.buildInternal(Workspace.java:515)
	at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:405)
	at org.eclipse.ui.actions.GlobalBuildAction$1.run(GlobalBuildAction.java:180)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
@MeAmAnUsername MeAmAnUsername added the C-Bug Category: bug. Not working as expected label Jun 1, 2022
@Gohla
Copy link
Member

Gohla commented Jun 8, 2022

This happens due to the key function in Sdf3ParseTableToFile, which causes this problem in bottom-up builds due to the task being visited twice with a different parse table supplier (which in turn is based on the main source file). Simply removing the key may cause problems with overlapping provided files.

We need to investigate whether removing the key will cause overlapping provided files. If so, we need to figure out how to solve this.

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
Projects
None yet
Development

No branches or pull requests

2 participants