Skip to content

Commit

Permalink
Fix crashes with verification coverage + counterexamples (#817)
Browse files Browse the repository at this point in the history
Previously, running Boogie with `/trackVerificationCoverage` and
`/enhancedErrorMessages:1` (or anything that leads to counterexample
parsing) would lead to crashes when verification failed. This fixes that
issue.
  • Loading branch information
atomb authored Nov 29, 2023
1 parent 1633ca6 commit 14194ca
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- Target framework and package configuration -->
<PropertyGroup>
<Version>3.0.7</Version>
<Version>3.0.8</Version>
<TargetFramework>net6.0</TargetFramework>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Authors>Boogie</Authors>
Expand Down
3 changes: 3 additions & 0 deletions Source/Model/ParserZ3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ internal override void Run()
}
else
{
if (funName.StartsWith("aux$$")) {
continue;
}
var fn = currModel.MkFunc(funName, 0);
fn.SetConstant(GetElt(lastWord));
}
Expand Down
4 changes: 3 additions & 1 deletion Source/Provers/SMTLib/SMTLibBatchTheoremProver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ private async Task<Outcome> CheckSat(CancellationToken cancellationToken)

if (options.LibOptions.ProduceUnsatCores) {
var unsatCoreSExp = responseStack.Pop();
ReportCoveredElements(unsatCoreSExp);
if (result == Outcome.Valid) {
ReportCoveredElements(unsatCoreSExp);
}
}

if (result == Outcome.Invalid) {
Expand Down
2 changes: 2 additions & 0 deletions Source/Provers/SMTLib/SMTLibProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ private async Task<SExpr> GetProverResponse()
return resp;
} else if (resp.Arguments[0].Name.Contains("model is not available")) {
return null;
} else if (resp.Arguments[0].Name.Contains("unsat core is not available")) {
return null;
} else if (resp.Arguments[0].Name.Contains("context is unsatisfiable")) {
return null;
} else if (resp.Arguments[0].Name.Contains("Cannot get model")) {
Expand Down
6 changes: 6 additions & 0 deletions Test/coverage/verificationCoverageCounterexample.bpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: %boogie /trackVerificationCoverage /enhancedErrorMessages:1 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
procedure P(x: int) {
assume {:id "id1"} x < 100;
assert {:id "id2"} x < 10;
}
5 changes: 5 additions & 0 deletions Test/coverage/verificationCoverageCounterexample.bpl.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
verificationCoverageCounterexample.bpl(5,3): Error: this assertion could not be proved
Execution trace:
verificationCoverageCounterexample.bpl(4,3): anon0

Boogie program verifier finished with 0 verified, 1 error

0 comments on commit 14194ca

Please sign in to comment.