Skip to content

Commit

Permalink
SMT2 back-end: report error when invoking solver fails
Browse files Browse the repository at this point in the history
Our previous attempt at reporting errors was dead code for `run` never
returns a negative value. When the executable isn't found the return
code was 1, which is also a legitimate return code when `z3` runs
successfully. Thus, use emptiness of `stderr` output as the success
criterion, and propagate the messages produced by `run` on stderr to the
error-logging output.

Fixes: #8362
  • Loading branch information
tautschnig committed Jul 12, 2024
1 parent 629dbcd commit 7fd93be
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/solvers/smt2/smt2_dec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Author: Daniel Kroening, [email protected]

#include "smt2irep.h"

#include <filesystem>

Check warning on line 18 in src/solvers/smt2/smt2_dec.cpp

View check run for this annotation

Codecov / codecov/patch

src/solvers/smt2/smt2_dec.cpp#L18

Added line #L18 was not covered by tests

std::string smt2_dect::decision_procedure_text() const
{
// clang-format off
Expand Down Expand Up @@ -135,13 +137,14 @@ decision_proceduret::resultt smt2_dect::dec_solve(const exprt &assumption)
UNREACHABLE;
}

int res =
run(argv[0], argv, stdin_filename, temp_file_stdout(), temp_file_stderr());
run(argv[0], argv, stdin_filename, temp_file_stdout(), temp_file_stderr());

if(res<0)
if(!std::filesystem::is_empty(temp_file_stderr()))
{
messaget log{message_handler};
log.error() << "error running SMT2 solver" << messaget::eom;
std::ifstream stderr_stream(temp_file_stderr());
log.error() << "error running SMT2 solver: " << stderr_stream.rdbuf()
<< messaget::eom;

Check warning on line 147 in src/solvers/smt2/smt2_dec.cpp

View check run for this annotation

Codecov / codecov/patch

src/solvers/smt2/smt2_dec.cpp#L145-L147

Added lines #L145 - L147 were not covered by tests
return decision_proceduret::resultt::D_ERROR;
}

Expand Down

0 comments on commit 7fd93be

Please sign in to comment.