-
Notifications
You must be signed in to change notification settings - Fork 273
Incorrect location coverage results in the presence of assumptions #7806
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
Comments
Remark: rewriting assumptions from int main() {
int i;
int j;
j = i;
if(j == i) __CPROVER_assume(0);
j = i + 2;
assert(j % 2 == 0);
return 0;
}
But extrapolating block reachability to location reachability in the presence of assumptions is still basically unsound. |
Just a quick comment to re-iterate what was said in our meeting this afternoon - We can resolve your immediate problems by adding a new coverage option to insert the kind of coverage instrumentation which you are looking for. In doing so we can leave the existing coverage options as is in order to avoid creating compatibly issues or surprise changes in behaviour for users of the existing options. |
@remi-delmas-3000 Are you aware of the existing
I am aware that this doesn't necessarily fit your exact needs, but it seems to be half way there. I am thinking that if we add something along the line of a |
Hi @thomasspriggs Indeed, by adding reachability assertions at block enty and after every assumption you could derive proper location coverage within a block without having to split the block. However I really think that fixing |
Hi @remi-delmas-3000 I have begun working on implementing a fix for this issue. Here is a progress update. There is an '#ifdef`'d out option for terminating coverage blocks on the assume instructions in goto programs here - https://github.com/diffblue/cbmc/blob/develop/src/goto-instrument/cover_basic_blocks.cpp#L76-L81 However the results of flipping this are not quite what you might expect. When performing coverage checks the assertions are replaced with assumptions. So if the various coverage checks are enabled, the combined result is multiple coverage goals for same line of code. I will be looking at options for avoiding this somewhat counter intuitive result next. |
@remi-delmas-3000 Could you try out the changes in the linked PR? |
I have merged this PR - #7810 |
Hi,
we have encountered a problem with the way coverage information is reported for
--cover location
in the presence of assumptions.Consider this program:
It compiles down to a single GOTO basic block that has an assumption in the middle.
The name of the switch
--cover location
makes it seem like it should produces location coverage information.In reality it instruments each block with a reachability assertion and extrapolates block reachability to all instructions of the block, and their corresponding source lines.
On this program it makes it look like all locations are reachable:
The problem is that an assumption can introduce a contradiction which can make subsequent instructions unreachable (lines 6-9) (the path constraint is infeasible).
To derive proper location coverage from block coverage, assumptions should be treated as delimiting the end of a basic block, since progress can stop if the assumption introduces a contradiction.
Correct location coverage results would then look like this:
I'm also suggesting to rename the option
--cover basic_block
to avoid the confusion with location/line coverage.CBMC version: 5.87.0
Operating system: all
Exact command line resulting in the issue: cbmc --cover location
What behaviour did you expect: some locations in this program are not reachable
What happened instead: all locations are reported as reachable
The text was updated successfully, but these errors were encountered: