Skip to content

Commit

Permalink
be nicer when memout is reached in SMT internalize: return undef rath…
Browse files Browse the repository at this point in the history
…er than crashing
  • Loading branch information
nunoplopes committed Dec 29, 2022
1 parent 7cc58c9 commit 47324af
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
41 changes: 30 additions & 11 deletions src/smt/smt_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2961,7 +2961,11 @@ namespace smt {
pop_to_base_lvl();
setup_context(false);
bool was_consistent = !inconsistent();
internalize_assertions(); // internalize assertions before invoking m_asserted_formulas.push_scope
try {
internalize_assertions(); // internalize assertions before invoking m_asserted_formulas.push_scope
} catch (cancel_exception&) {
throw default_exception("Resource limits hit in push");
}
if (!m.inc())
throw default_exception("push canceled");
scoped_suspend_rlimit _suspend_cancel(m.limit());
Expand Down Expand Up @@ -3556,7 +3560,12 @@ namespace smt {
return p(asms);
}

internalize_assertions();
try {
internalize_assertions();
} catch (cancel_exception&) {
VERIFY(resource_limits_exceeded());
return l_undef;
}
expr_ref_vector theory_assumptions(m);
add_theory_assumptions(theory_assumptions);
if (!theory_assumptions.empty()) {
Expand Down Expand Up @@ -3620,10 +3629,15 @@ namespace smt {
do {
pop_to_base_lvl();
expr_ref_vector asms(m, num_assumptions, assumptions);
internalize_assertions();
add_theory_assumptions(asms);
TRACE("unsat_core_bug", tout << asms << "\n";);
init_assumptions(asms);
try {
internalize_assertions();
add_theory_assumptions(asms);
TRACE("unsat_core_bug", tout << asms << '\n';);
init_assumptions(asms);
} catch (cancel_exception&) {
VERIFY(resource_limits_exceeded());
return l_undef;
}
TRACE("before_search", display(tout););
r = search();
r = mk_unsat_core(r);
Expand All @@ -3641,11 +3655,16 @@ namespace smt {
do {
pop_to_base_lvl();
expr_ref_vector asms(cube);
internalize_assertions();
add_theory_assumptions(asms);
// introducing proxies: if (!validate_assumptions(asms)) return l_undef;
for (auto const& clause : clauses) if (!validate_assumptions(clause)) return l_undef;
init_assumptions(asms);
try {
internalize_assertions();
add_theory_assumptions(asms);
// introducing proxies: if (!validate_assumptions(asms)) return l_undef;
for (auto const& clause : clauses) if (!validate_assumptions(clause)) return l_undef;
init_assumptions(asms);
} catch (cancel_exception&) {
VERIFY(resource_limits_exceeded());
return l_undef;
}
for (auto const& clause : clauses) init_clause(clause);
r = search();
r = mk_unsat_core(r);
Expand Down
2 changes: 2 additions & 0 deletions src/smt/smt_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ namespace smt {

class model_generator;

struct cancel_exception {};

class context {
friend class model_generator;
friend class lookahead;
Expand Down
2 changes: 1 addition & 1 deletion src/smt/smt_internalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ namespace smt {
*/
void context::internalize(expr * n, bool gate_ctx) {
if (memory::above_high_watermark())
throw default_exception("resource limit exceeded during internalization");
throw cancel_exception();
internalize_deep(n);
internalize_rec(n, gate_ctx);
}
Expand Down

0 comments on commit 47324af

Please sign in to comment.