Fix segfault by making unit conflict CDMaybe
authorAndres Nötzli <andres.noetzli@gmail.com>
Fri, 16 Jun 2017 18:16:04 +0000 (11:16 -0700)
committerGitHub <noreply@github.com>
Fri, 16 Jun 2017 18:16:04 +0000 (11:16 -0700)
This commit fixes bug 819 by making d_unitConflictId context dependent and adds a test case.

src/proof/sat_proof.h
src/proof/sat_proof_implementation.h
test/regress/regress0/push-pop/Makefile.am
test/regress/regress0/push-pop/simple_unsat_cores.smt2 [new file with mode: 0644]

index 5691d1bd2118782784f3ab4595d37f68c0d054f4..36de6278ac433962fca0a36e41ee021ff46d39eb 100644 (file)
@@ -29,6 +29,7 @@
 #include <vector>
 
 #include "context/cdhashmap.h"
+#include "context/cdmaybe.h"
 #include "expr/expr.h"
 #include "proof/clause_id.h"
 #include "proof/proof_manager.h"
@@ -349,8 +350,7 @@ class TSatProof {
   IdCRefMap d_temp_idClause;
 
   // unit conflict
-  ClauseId d_unitConflictId;
-  bool d_storedUnitConflict;
+  context::CDMaybe<ClauseId> d_unitConflictId;
 
   ClauseId d_trueLit;
   ClauseId d_falseLit;
index eb4e04d1336796f6b36f0974adb66e98e42edf51..6cb10450acba87ef6e99c94797e5daed02100e41 100644 (file)
@@ -218,8 +218,7 @@ TSatProof<Solver>::TSatProof(Solver* solver, context::Context* context,
       d_nullId(-2),
       d_temp_clauseId(),
       d_temp_idClause(),
-      d_unitConflictId(),
-      d_storedUnitConflict(false),
+      d_unitConflictId(context),
       d_trueLit(ClauseIdUndef),
       d_falseLit(ClauseIdUndef),
       d_name(name),
@@ -867,12 +866,11 @@ template <class Solver>
 ClauseId TSatProof<Solver>::storeUnitConflict(
     typename Solver::TLit conflict_lit, ClauseKind kind) {
   Debug("cores") << "STORE UNIT CONFLICT" << std::endl;
-  Assert(!d_storedUnitConflict);
-  d_unitConflictId = registerUnitClause(conflict_lit, kind);
-  d_storedUnitConflict = true;
-  Debug("proof:sat:detailed") << "storeUnitConflict " << d_unitConflictId
+  Assert(!d_unitConflictId.isSet());
+  d_unitConflictId.set(registerUnitClause(conflict_lit, kind));
+  Debug("proof:sat:detailed") << "storeUnitConflict " << d_unitConflictId.get()
                               << "\n";
-  return d_unitConflictId;
+  return d_unitConflictId.get();
 }
 
 template <class Solver>
@@ -881,8 +879,8 @@ void TSatProof<Solver>::finalizeProof(typename Solver::TCRef conflict_ref) {
   Assert(conflict_ref != Solver::TCRef_Undef);
   ClauseId conflict_id;
   if (conflict_ref == Solver::TCRef_Lazy) {
-    Assert(d_storedUnitConflict);
-    conflict_id = d_unitConflictId;
+    Assert(d_unitConflictId.isSet());
+    conflict_id = d_unitConflictId.get();
 
     ResChain<Solver>* res = new ResChain<Solver>(conflict_id);
     typename Solver::TLit lit = d_idUnit[conflict_id];
@@ -892,7 +890,7 @@ void TSatProof<Solver>::finalizeProof(typename Solver::TCRef conflict_ref) {
     return;
 
   } else {
-    Assert(!d_storedUnitConflict);
+    Assert(!d_unitConflictId.isSet());
     conflict_id = registerClause(conflict_ref, LEARNT);  // FIXME
   }
 
index 262132779385037c5ccaf9e08b531992a5be9d00..197f81d63b799c1ec44a87253628aec9ea2afa42 100644 (file)
@@ -48,7 +48,8 @@ BUG_TESTS = \
   inc-define.smt2 \
   bug765.smt2 \
   bug691.smt2 \
-  bug694-Unapply1.scala-0.smt2
+  bug694-Unapply1.scala-0.smt2 \
+  simple_unsat_cores.smt2
 
 TESTS =        $(SMT_TESTS) $(SMT2_TESTS) $(CVC_TESTS) $(BUG_TESTS)
 
diff --git a/test/regress/regress0/push-pop/simple_unsat_cores.smt2 b/test/regress/regress0/push-pop/simple_unsat_cores.smt2
new file mode 100644 (file)
index 0000000..e85a546
--- /dev/null
@@ -0,0 +1,10 @@
+; COMMAND-LINE: --incremental
+; EXPECT: unsat
+; EXPECT: unsat
+(set-logic UF)
+(push 1)
+(assert false)
+(check-sat)
+(pop 1)
+(assert false)
+(check-sat)