Skip to content

Relax module duplication check#2972

Merged
rv-jenkins merged 7 commits intodevelopfrom
fix2910
Oct 17, 2022
Merged

Relax module duplication check#2972
rv-jenkins merged 7 commits intodevelopfrom
fix2910

Conversation

@radumereuta
Copy link
Copy Markdown
Contributor

@radumereuta radumereuta commented Oct 10, 2022

Allows for file copy by checking: 1. filename 2. location and 3. module digest
Fixes: #2910

Allows for file copy by checking filename and module digest
Fixes: #2910
@radumereuta radumereuta self-assigned this Oct 10, 2022
to better match the actual check.
Avoids changing the definition and therefore changing the output of kore-exec
Comment thread kernel/src/main/java/org/kframework/parser/ParserUtils.java Outdated
Copy link
Copy Markdown
Contributor

@Baltoli Baltoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the error message in the test here is particularly clear - the modules here are in fact identical, but happen to be declared in the same file. We probably want to distinguish (if possible) this case from "the exact same module, but moved on disk".

Copy link
Copy Markdown
Contributor

@dwightguth dwightguth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some concerns; you probably also want to add digest to the reserved attribute list in the documentation.

Comment thread kernel/src/main/java/org/kframework/kil/Module.java Outdated
// Tuple3 of moduleName, Source, Location
Map<String, List<Tuple3<String, Source, Location>>> groupedModules =
// Tuple3 of moduleName, Source, Location, digest
Map<String, List<Tuple4<String, Source, Location, Long>>> groupedModules =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably not what you want. The tuple of String, Source, Location was being used to identify modules that appeared in two places with different filenames or locations. You probably just instead want to identify two modules that have the same name but different contents, in which case you really only need module name and digest in the value of the map.

+ firstMod._2() + " and " + firstMod._3(), secondMod._2(), secondMod._3());
errors++;
kem.addKException(ex.getKException());
// give an error message only if we have
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you do what I suggested above, we don't really need this check.

genPriorityGroups(priorityList, priorityToPreviousGroup, priorityToAlias, topCellSortStr, semantics);
semantics.append("endmodule ");
convert(attributes, module.att(), semantics, null, null);
convert(attributes, module.att().remove(Att.DIGEST()), semantics, null, null);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing this, let's just remove the digest attribute when converting from a FlatModule back to a Module.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not going to work for kprove.
We store CompileDefinition.parsedDefinition which has Module.
If we strip that attribute we won't have it when we do slurp in kprove. Which is where the failure happens.

@dwightguth
Copy link
Copy Markdown
Contributor

dwightguth commented Oct 12, 2022

Okay I am now very confused about exactly what this change is supposed to be fixing. Let's discuss in the meeting tomorrow. I don't understand why kprove would be worried about duplicate modules having a different location unless it's reparsing the definition during proof time, which it should not be doing anymore.

- better hashing
- comments
@radumereuta
Copy link
Copy Markdown
Contributor Author

Guessing by the comments on this PR, all 3 of us have different opinions on what should happen when we encounter duplicate modules.
This PR tries to solve a problem in kprove that appears very often in KEVM because of how the running scripts work there.
If you kompile a definition, and then move the files somewhere else, and run kprove, then you will run into this issue.
This can happen when you require "domains.md". Outer parsing will recursively go through all the files and only later will compare if those modules do exist in the already compiled definition.

My implementation is the most strict I can think of. It only allows for moving files around.
@dwightguth you proposed to only check for module-name and digest. That would not work for duplicate modules in the same file. Like the test I modified in this PR. Maybe Bruce is right. We should have a somewhat different error message for that case.

Let's discuss this in the KDev meeting tomorrow.

@dwightguth
Copy link
Copy Markdown
Contributor

We probably should just keep all modules in the definition in lexical scope when parsing kprove and then make it an error to redeclare any of them in your spec module, including via requires. Then you're not reparsing modules that have already been parsed, and you won't have this issue even without needing to keep track of a cryptographic hash of the module.

@radumereuta radumereuta linked an issue Oct 13, 2022 that may be closed by this pull request
@radumereuta
Copy link
Copy Markdown
Contributor Author

We sometimes require "domains.md" in the spec file is because of this issue: #1890

Comment thread kernel/src/main/java/org/kframework/parser/ParserUtils.java
@rv-jenkins rv-jenkins merged commit 186e5aa into develop Oct 17, 2022
@rv-jenkins rv-jenkins deleted the fix2910 branch October 17, 2022 21:03
@radumereuta radumereuta linked an issue Oct 19, 2022 that may be closed by this pull request
5 tasks
@radumereuta radumereuta removed a link to an issue Oct 19, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiled binaries are not portable (problem with Nix builds)

4 participants