From f64d077d2afe17f19a97f0a86578d37cdd1689a2 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 16 Nov 2024 12:29:03 -0800 Subject: [PATCH] fix re-entrancy bug during flip in arith_base --- src/ast/sls/sls_arith_base.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ast/sls/sls_arith_base.cpp b/src/ast/sls/sls_arith_base.cpp index c201d9ef3bf..e3aa9ff016b 100644 --- a/src/ast/sls/sls_arith_base.cpp +++ b/src/ast/sls/sls_arith_base.cpp @@ -668,14 +668,13 @@ namespace sls { return false; } - - #if 0 if (!check_update(v, new_value)) return false; apply_checked_update(); #else + buffer to_flip; for (auto const& [coeff, bv] : vi.m_bool_vars) { auto& ineq = *atom(bv); bool old_sign = sign(bv); @@ -684,14 +683,19 @@ namespace sls { ineq.m_args_value += coeff * (new_value - old_value); num_t dtt_new = dtt(old_sign, ineq); if (dtt_new != 0) - ctx.flip(bv); - SASSERT(dtt(sign(bv), ineq) == 0); + to_flip.push_back(bv); + } IF_VERBOSE(5, verbose_stream() << "repair: v" << v << " := " << old_value << " -> " << new_value << "\n"); vi.m_value = new_value; ctx.new_value_eh(e); m_last_var = v; + for (auto bv : to_flip) { + ctx.flip(bv); + SASSERT(dtt(sign(bv), *atom(bv)) == 0); + } + IF_VERBOSE(10, verbose_stream() << "new value eh " << mk_bounded_pp(e, m) << "\n"); for (auto idx : vi.m_muls) @@ -2008,7 +2012,7 @@ namespace sls { } if (n == value(w)) return true; - return update(w, n); + return update(w, n); } template @@ -2292,8 +2296,9 @@ namespace sls { for (auto const& [c, v] : i.m_args) val += c * value(v); if (val != i.m_args_value) - verbose_stream() << i << "\n"; + verbose_stream() << val << ": " << i << "\n"; SASSERT(val == i.m_args_value); + VERIFY(val == i.m_args_value); }