-
Notifications
You must be signed in to change notification settings - Fork 273
[TG-3657] Always load CProver.nondetInitialize #2267
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
Merged
romainbrenguier
merged 2 commits into
diffblue:develop
from
LAJW:lajw/always-load-cprover-nondet-initialize
Jun 5, 2018
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+478 Bytes
jbmc/regression/jbmc/cprover-always-load-nondet-initialize/ObjectWithNondetInitialize.class
Binary file not shown.
11 changes: 11 additions & 0 deletions
11
jbmc/regression/jbmc/cprover-always-load-nondet-initialize/ObjectWithNondetInitialize.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import org.cprover.CProver; | ||
|
||
class ObjectWithNondetInitialize { | ||
private int value_; | ||
public void cproverNondetInitialize() { | ||
CProver.assume(value_ == 13); | ||
} | ||
public int value() { | ||
return value_; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
jbmc/regression/jbmc/cprover-always-load-nondet-initialize/Opaque.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import org.cprover.CProver; | ||
|
||
public class Opaque { | ||
public ObjectWithNondetInitialize get() { | ||
return new ObjectWithNondetInitialize(); | ||
} | ||
} |
Binary file added
BIN
+363 Bytes
jbmc/regression/jbmc/cprover-always-load-nondet-initialize/Test.class
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
jbmc/regression/jbmc/cprover-always-load-nondet-initialize/Test.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class Test { | ||
public int test() { | ||
return (new Opaque()).get().value(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
jbmc/regression/jbmc/cprover-always-load-nondet-initialize/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
KNOWNBUG | ||
Test.class | ||
--function Test.test --show-goto-functions --lazy-methods | ||
EXIT=0 | ||
SIGNAL=0 | ||
ObjectWithNondetInitialize\.cproverNondetInitialize\(\) | ||
-- | ||
-- | ||
Check if cproverNondetInitialize method is loaded in an object | ||
returned from an opaque method | ||
https://github.com/diffblue/cbmc/issues/2273 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely you should also actually populate them!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have to populate anything - all of these variables are local and are used to produce this
methods_already_populated
set, which is then used to filter out things to not remove (it looks like). Most of them are badly named. For instance this one should be calledmethods_to_load
and probably generated by a separate method.I initially wanted to refactor this function, but since lazy loading V2 development is in full swing, I decided that would be a wasted effort. If my assumption was wrong, I'll create another PR that cleans this up, and leave this one alone for the sake of merging this fix on time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant, you should ensure the method actually is converted, not just put it in an "already_populated" set. Doing that will stop it being removed from the symbol table; putting it into the worklist will get the symbol's value (the method body) populated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the method body is populated. Otherwise it wouldn't fix the test-gen bug, which is what this change was all about. Really, the only problem is with preexisting misleading variable names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea how it's getting populated without being added to
methods_already_populated
(whose name is accurate, it is an accumulation of methods that have been populated by the method converting loop above)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe because there is a special case for it in
add_needed_class
? https://github.com/diffblue/cbmc/blob/develop/jbmc/src/java_bytecode/ci_lazy_methods_needed.cpp#L41There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would result in its being added to the worklist and converted (and thus retained) in the usual way. Somehow its body is being filled in without going through the
ci_lazy_methodst
mechanism. Last I heard @LAJW was trying to find out why and submit a fix PR (or justify the status quo)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it works:
After the
typecheck
phase in which theci_lazy_methodst
is run, there is a separatelazy_goto_model.load_all_functions();
which ensures all symbols are loaded so actually loads the method.This fix shouldn't be required because, as @romainbrenguier points out, it is already added to the needed methods by
ci_lazy_methods_needed
. The problem (I suppose) is that a return type of an opaque method is not sufficient to cause loading that type. This is certainly wrong for test-gen, which will stub that method and try and create the object of that type. @smowton do you have an oppinion on whether that is correct for CBMC? That is:Should
Foo
be loaded?