Skip to content

Commit

Permalink
Fix hanging when solver exits with a non-zero exit code (#821)
Browse files Browse the repository at this point in the history
Previously, if the solver quit abruptly with a non-zero exit code (such
as for a segmentation fault), Boogie would hang. These changes turn that
into a well-behaved solver exception.

---------

Co-authored-by: Remy Willems <[email protected]>
  • Loading branch information
atomb and keyboardDrummer authored Dec 6, 2023
1 parent c545628 commit 4896769
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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.8</Version>
<Version>3.0.9</Version>
<TargetFramework>net6.0</TargetFramework>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Authors>Boogie</Authors>
Expand Down
5 changes: 5 additions & 0 deletions Source/Provers/SMTLib/SMTLibProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public SMTLibProcess(SMTLibOptions libOptions, SMTLibSolverOptions options)
{
solver = new Process();
solver.StartInfo = psi;
solver.EnableRaisingEvents = true;
solver.ErrorDataReceived += SolverErrorDataReceived;
solver.OutputDataReceived += SolverOutputDataReceived;
solver.Exited += SolverExited;
Expand All @@ -74,6 +75,10 @@ public SMTLibProcess(SMTLibOptions libOptions, SMTLibSolverOptions options)

private void SolverExited(object sender, EventArgs e)
{
if (options.Verbosity >= 2) {
Console.WriteLine($"[SMT-ERR-{{0}}] Solver exited with code {solver.ExitCode}.");
}

lock (this) {
while (outputReceivers.TryDequeue(out var source)) {
source.SetResult(null);
Expand Down
8 changes: 8 additions & 0 deletions Test/prover/exitcode.bpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: %parallel-boogie /proverOpt:PROVER_PATH=/usr/bin/false "%s" > "%t"
// RUN: %OutputCheck --file-to-check "%t" "%s"
// CHECK: exitcode.bpl\(6,11\): Verification encountered solver exception \(P\)
// CHECK: Boogie program verifier finished with 0 verified, 0 errors, 1 solver exceptions

procedure P(x: int, y: int) {
assert x*y == y*x;
}

0 comments on commit 4896769

Please sign in to comment.