mirror of
https://github.com/Z3Prover/z3
synced 2026-06-20 07:36:31 +00:00
add exception handling in case run method throws
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
f2270d4654
commit
96092b196c
2 changed files with 24 additions and 9 deletions
|
|
@ -120,9 +120,7 @@ namespace smt {
|
|||
}
|
||||
else {
|
||||
// selected parameters are safe to update after initialization
|
||||
params_ref new_p;
|
||||
new_p.set_uint("max_conflicts", p.get_uint("max_conflicts", UINT_MAX));
|
||||
m_fparams.updt_params(new_p);
|
||||
m_fparams.m_max_conflicts = p.get_uint("max_conflicts", m_fparams.m_max_conflicts);
|
||||
}
|
||||
for (auto th : m_theory_set)
|
||||
if (th)
|
||||
|
|
@ -4685,7 +4683,6 @@ namespace smt {
|
|||
theory_id th_id = l->get_id();
|
||||
|
||||
for (enode * parent : enode::parents(n)) {
|
||||
auto p = parent->get_expr();
|
||||
family_id fid = parent->get_family_id();
|
||||
if (fid != th_id && fid != m.get_basic_family_id()) {
|
||||
if (is_beta_redex(parent, n))
|
||||
|
|
|
|||
|
|
@ -883,7 +883,7 @@ class parallel_solver {
|
|||
if (lim.is_canceled() || m_state != state::is_running)
|
||||
return false;
|
||||
|
||||
if (m_bb_last_batch_processed[bb_thread_id] == m_bb_batch_id) {
|
||||
if (m_bb_last_batch_processed[bb_thread_id] == m_bb_batch_id) {
|
||||
unsigned n = std::min<unsigned>(m_bb_batch_size, m_bb_candidates.size());
|
||||
m_bb_current_batch.reset();
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
|
|
@ -1912,14 +1912,32 @@ public:
|
|||
|
||||
m_batch_manager.initialize(num_bb_threads);
|
||||
|
||||
auto safe_run = [&](std::function<void()> run_fn, reslimit& lim) {
|
||||
try {
|
||||
run_fn();
|
||||
} catch (z3_error &err) {
|
||||
if (!lim.is_canceled())
|
||||
m_batch_manager.set_exception(err.error_code());
|
||||
} catch (z3_exception &ex) {
|
||||
if (!lim.is_canceled() && !is_cancellation_exception(ex.what()))
|
||||
m_batch_manager.set_exception(ex.what());
|
||||
}
|
||||
};
|
||||
/* Launch threads. */
|
||||
vector<std::thread> threads;
|
||||
for (auto* w : m_workers)
|
||||
threads.push_back(std::thread([w]() { w->run(); }));
|
||||
for (auto *w : m_workers)
|
||||
threads.push_back(std::thread([&]() {
|
||||
safe_run([w]() -> void { w->run(); }, w->limit());
|
||||
}));
|
||||
if (m_core_minimizer_worker)
|
||||
threads.push_back(std::thread([this]() { m_core_minimizer_worker->run(); }));
|
||||
threads.push_back(std::thread([&]() {
|
||||
safe_run([this]() -> void { m_core_minimizer_worker->run(); }, m_core_minimizer_worker->limit());
|
||||
}));
|
||||
for (auto* w : m_global_backbones_workers)
|
||||
threads.push_back(std::thread([w]() { w->run(); }));
|
||||
threads.push_back(std::thread([&]() {
|
||||
safe_run([w]() -> void {
|
||||
w->run(); }, w->limit());
|
||||
}));
|
||||
|
||||
for (auto& t : threads)
|
||||
t.join();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue