Skip to content

Commit 834b695

Browse files
committed
CVC4: catch/handle exceptions from prover context.
1 parent 3aff21d commit 834b695

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/org/sosy_lab/java_smt/solvers/cvc4/CVC4TheoremProver.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.google.common.base.Preconditions;
1212
import com.google.common.collect.Collections2;
1313
import com.google.common.collect.ImmutableList;
14+
import edu.stanford.CVC4.Exception;
1415
import edu.stanford.CVC4.Expr;
1516
import edu.stanford.CVC4.ExprManager;
1617
import edu.stanford.CVC4.ExprManagerMapCollection;
@@ -123,16 +124,25 @@ protected void popImpl() {
123124
}
124125

125126
@Override
126-
protected @Nullable Void addConstraintImpl(BooleanFormula pF) throws InterruptedException {
127+
protected @Nullable Void addConstraintImpl(BooleanFormula pF)
128+
throws InterruptedException, SolverException {
127129
Preconditions.checkState(!closed);
128130
setChanged();
129-
Expr exp = creator.extractInfo(pF);
130131
if (incremental) {
131-
smtEngine.assertFormula(importExpr(exp));
132+
assertFormula(pF);
132133
}
133134
return null;
134135
}
135136

137+
private void assertFormula(BooleanFormula pF) throws SolverException {
138+
try {
139+
smtEngine.assertFormula(importExpr(creator.extractInfo(pF)));
140+
} catch (Exception cvc4Exception) {
141+
throw new SolverException(
142+
String.format("CVC4 crashed while adding the constraint '%s'", pF), cvc4Exception);
143+
}
144+
}
145+
136146
@SuppressWarnings("resource")
137147
@Override
138148
public CVC4Model getModel() throws InterruptedException, SolverException {
@@ -188,7 +198,9 @@ public boolean isUnsat() throws InterruptedException, SolverException {
188198
closeAllEvaluators();
189199
changedSinceLastSatQuery = false;
190200
if (!incremental) {
191-
getAssertedFormulas().forEach(f -> smtEngine.assertFormula(creator.extractInfo(f)));
201+
for (BooleanFormula f : getAssertedFormulas()) {
202+
assertFormula(f);
203+
}
192204
}
193205

194206
Result result;

0 commit comments

Comments
 (0)