diff --git a/scripts/update_api.py b/scripts/update_api.py index 09b325909..ec3fe4903 100755 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -1691,7 +1691,7 @@ def write_log_h_preamble(log_h): log_h.write('#include\n') log_h.write('extern std::ostream * g_z3_log;\n') log_h.write('extern std::atomic g_z3_log_enabled;\n') - log_h.write('class z3_log_ctx { bool m_prev; public: z3_log_ctx() { m_prev = g_z3_log_enabled.exchange(false); } ~z3_log_ctx() { g_z3_log_enabled = m_prev; } bool enabled() const { return m_prev; } };\n') + log_h.write('class z3_log_ctx { bool m_prev; public: z3_log_ctx() { m_prev = g_z3_log && g_z3_log_enabled.exchange(false); } ~z3_log_ctx() { if (g_z3_log) g_z3_log_enabled = m_prev; } bool enabled() const { return m_prev; } };\n') log_h.write('inline void SetR(void * obj) { *g_z3_log << "= " << obj << "\\n"; }\ninline void SetO(void * obj, unsigned pos) { *g_z3_log << "* " << obj << " " << pos << "\\n"; } \ninline void SetAO(void * obj, unsigned pos, unsigned idx) { *g_z3_log << "@ " << obj << " " << pos << " " << idx << "\\n"; }\n') log_h.write('#define RETURN_Z3(Z3RES) if (_LOG_CTX.enabled()) { SetR(Z3RES); } return Z3RES\n') log_h.write('void _Z3_append_log(char const * msg);\n') diff --git a/src/api/api_log.cpp b/src/api/api_log.cpp index e82ec3fd1..4269a2c52 100644 --- a/src/api/api_log.cpp +++ b/src/api/api_log.cpp @@ -35,8 +35,8 @@ static std::mutex g_log_mux; extern "C" { void Z3_close_log_unsafe(void) { if (g_z3_log != nullptr) { - dealloc(g_z3_log); g_z3_log_enabled = false; + dealloc(g_z3_log); g_z3_log = nullptr; } } diff --git a/src/ast/rewriter/th_rewriter.cpp b/src/ast/rewriter/th_rewriter.cpp index dcb995ada..7f50145de 100644 --- a/src/ast/rewriter/th_rewriter.cpp +++ b/src/ast/rewriter/th_rewriter.cpp @@ -107,7 +107,8 @@ struct th_rewriter_cfg : public default_rewriter_cfg { bool cache_all_results() const { return m_cache_all; } bool max_steps_exceeded(unsigned num_steps) const { - if (memory::get_allocation_size() > m_max_memory) + if (m_max_memory != SIZE_MAX && + memory::get_allocation_size() > m_max_memory) throw rewriter_exception(Z3_MAX_MEMORY_MSG); return num_steps > m_max_steps; }